option to show ppin names/info on import\r
center and size map on annotations.\r
\r
- Get lat & lon for journey route points not matched to pushpins\r
Get point info for non-line annotations, e.g. text boxes.\r
import route as s&t route (Journey), i.e. not just as a line.\r
- fix overuse of realloc\r
support unicode names (remove str2ascii)\r
\r
different colours for imported routes & tracks\r
\r
support drive-time zones in annotations stream?\r
\r
+ fix ppin import for longer renderdata\r
+\r
Still to test:\r
* various versions, esp import\r
* multiple imports\r
/*\r
annotations.c\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
#include "gpx.h"\r
#include "st2gpx.h"\r
#include "pushpins.h"\r
-\r
#include "annotations.h"\r
\r
+#ifdef EXPLORE\r
+#include "explore.h"\r
+#endif\r
+\r
+\r
// std_anotfile_header[8,9] are variable (number of annotations)\r
char std_annotfile_header[12] // num annots\r
= {0x34, 0x12, 0x00, 0x2d, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00};\r
// double magic2=0x10000;\r
\r
/*\r
-typedef struct annotationbuf\r
+struct annotationbuf\r
{\r
int annot_num;\r
int flags; // bit fields in first byte\r
int joinflag; // 0 line does not join, 1, joins. Not sure what large balues for non-lines mean - xscale?\r
char unkn4; // y-scale?\r
int num_points; // different meaning for non-lines\r
-} structannotationbuf;\r
+};\r
*/\r
\r
\r
nw->text = NULL;\r
nw->line_points=0;\r
nw->line_offset=0;\r
+ nw->is_closed_line_flag=0;\r
return nw;\r
}\r
\r
}\r
\r
struct gpxpt* gpx_get_point(char* buf)\r
+//struct gpxpt* gpx_get_point(struct annot_line_point* bufpt)\r
// Convert the 12-byte location structure in annotations stream to GPS coordinates.\r
{\r
struct gpxpt * pt = gpxpt_new();\r
y= *(float *)(buf + 4);\r
z= *(float *)(buf + 8);\r
\r
+// x=bufpt->x;\r
+// y=bufpt->y;\r
+// z=bufpt->z;\r
+\r
//printf("gpx_get_point x=%f y=%f z=%f\n",x,y,z);\r
pt->lat = atan2(z,sqrt(pow(x,2)+ pow(y,2)))*180/M_PI;\r
pt->lon = atan2(y,x)*180/M_PI;\r
return pt;\r
}\r
\r
+void print_annot_rec(struct annot_rec * rec)\r
+{\r
+ int bit_flags = *(int*)(rec->buf + 8);\r
+ char* rec_type = NULL;\r
+\r
+ if (rec->type<4)\r
+ rec_type =annot_type_name[rec->type];\r
+\r
+ printf("Got annotation id %d, of type %s, %d line points",\r
+ rec->annot_num, rec_type, rec->line_points);\r
+ if(rec->text !=NULL)\r
+ printf(" and text '%s'", rec->text);\r
+ printf("\n");\r
+ if (opts.verbose_flag > 4)\r
+ printf("(type=%d) text length %d, bitflags %#x buf length %d\n",\r
+ rec->type, rec->text_length, bit_flags, rec->length);\r
+}\r
+\r
struct annot_rec * read_annot_rec(FILE* annot_in_file, int version)\r
{\r
int status;\r
}\r
\r
// **********************\r
- // Read the record header, up to begining of possible text\r
+ // Read the record header\r
// **********************\r
\r
rec->buf = (char*)xmalloc(head_len);\r
status = readbytes(annot_in_file, rec->buf, head_len);\r
if (status!=head_len)\r
{\r
- //FIXME\r
-// gpx_write_file_trailer(gpx_out_file);\r
- // exit(1)\r
// should do some cleaning up here\r
return rec;\r
}\r
\r
+#ifdef EXPLORE\r
+ print_f_annotation_line_header(rec->buf, head_len, version);\r
+#endif\r
+\r
rec->type = *(int*)(rec->buf+ANNOT_RECOS_TYPE);\r
if (rec->type > 3 )\r
{\r
rec->annot_num = *(int*)(rec->buf+ANNOT_RECOS_ANUM);\r
// FIXME kludge, fit into the framework\r
bit_flags = *(int*)(rec->buf + 8);\r
- rec->text_length = *(int*)(rec->buf+text_len_offset);\r
+ rec->text_length = *(unsigned int*)(rec->buf + text_len_offset);\r
+\r
+ // ***********************\r
+ // Read extra for the text\r
+ // ***********************\r
+\r
+ // There can be text for lines!\r
+ // This reads the extra part of annot+headfor the text,\r
+ // but not the actual text\r
+\r
+ rec->buf = (char*)realloc(rec->buf, head_len + 2*(rec->text_length));\r
+ // This read can fail because I have miscalculated size or number of records\r
+ // So exit gracefully\r
+ status = readbytes(annot_in_file, rec->buf + head_len, 2*(rec->text_length));\r
+ if (status != 2*(rec->text_length))\r
+ {\r
+ // should do some cleaning up here\r
+ return rec;\r
+ }\r
+ head_len += 2*(rec->text_length);\r
+ line_offset += 2*(rec->text_length);\r
+\r
+ // ******************************\r
+ // Now we can get num line points\r
+ // ******************************\r
+\r
rec->line_points=0;\r
if (rec->type == ANNOT_TYPE_LINE)\r
- rec->line_points = *(int*)(rec->buf+head_len-4);\r
+ rec->line_points = *(unsigned int*)(rec->buf + head_len - 4 );\r
\r
// ***************************\r
// Calculate the record length\r
rec->length += 4;\r
\r
// FIXME This is a kludge\r
+ // **** Should use c_shape_points\r
+ // c_shape_points = 33 instead of 61, so file is 12*(61-33)=336\r
if (opts.st_version_num>10)\r
{\r
- if ( (rec->type == 1) || (rec->type == 4) )\r
+ if ( (rec->type == ANNOT_TYPE_OVAL) || (rec->type == ANNOT_TYPE_CIRCLE) )\r
{\r
- printf("Fudge: shortening 336 bytes from oval record length, but I dont know why.\n");\r
+ //printf("Fudge: shortening 336 bytes from oval record length, but I dont know why.\n");\r
(rec->length) -= 336;\r
}\r
}\r
str2ascii(rec->text);\r
}\r
\r
+ if (rec->type == ANNOT_TYPE_LINE)\r
+ {\r
+ rec->is_closed_line_flag = *(unsigned char*)(rec->buf + head_len - 9);\r
+ if( (rec->is_closed_line_flag != 0) && (rec->is_closed_line_flag != 1) )\r
+ printf("Unexpected is_closed_line_flag=%d\n", rec->is_closed_line_flag);\r
+ }\r
+\r
if (opts.verbose_flag > 1)\r
print_annot_rec(rec);\r
\r
FILE* annot_in_file=NULL;\r
struct annotations * annots = annotations_new();\r
\r
+ int readbyte;\r
+// int max_read_more;\r
+// int readmore;\r
+ char* readmorebuf=NULL;\r
+// char* strange=NULL;\r
+ float* strange_float=NULL;\r
+ struct annot_line_point * strange_pts=NULL;\r
+// struct gpxpt* strange_gpxpt;\r
+\r
annots->header_buf=(char*)xmalloc(ANNOT_FILE_HEAD_LEN);\r
\r
if ((annot_in_file = fopen(annot_in_file_name, "rb")) == NULL)\r
}\r
annots->stream_length += ANNOT_FILE_HEAD_LEN;\r
\r
- for (i=1; i<8; i++)\r
+ for (i=1; i<4; i++)\r
if ( annots->header_buf[i] != std_annotfile_header[i] )\r
printf("Nonstandard annotations file header, header[%i]=0x%x, normal value is 0x%x\n",\r
i, annots->header_buf[i], std_annotfile_header[i] );\r
\r
annots->version = *(int*)(annots->header_buf+4);\r
+ if ((annots->version < 3) || (annots->version > 4))\r
+ printf("Unexpected annotations version %d\n", annots->version);\r
+\r
annots->num_annotations = *(int*)(annots->header_buf+8);\r
\r
annots->annot_list = (struct annot_rec **)xmalloc(\r
{\r
rec = read_annot_rec(annot_in_file, annots->version);\r
\r
+#ifdef EXPLORE\r
if (opts.explore_flag)\r
- explore_annot(rec);\r
+ explore_annot(rec, annots->version);\r
+#endif\r
if (rec==NULL)\r
{\r
annots->read_recs_ok_flag = 0;\r
annots->stream_length += rec->length;\r
}\r
\r
+ // fudge for White_West_Sts.ptm was here\r
+\r
// Check that we are at the end of annotation file\r
if (read_tail_buff)\r
{\r
status=readbytes(annot_in_file, checkEOF, 4);\r
annots->stream_length += status;\r
if ( (status!=4) || (checkEOF[0]!=0) || (checkEOF[1]!=0)\r
- || (checkEOF[2]!=0) || (checkEOF[3]!=0) || (getc(annot_in_file)!=EOF) )\r
+ || (checkEOF[2]!=0) || (checkEOF[3]!=0) ||\r
+ (readbyte=getc(annot_in_file)!=EOF) )\r
{\r
fprintf (stderr, "Did not finish reading annotation file at EOF\n");\r
+ //ungetc(readbyte, annot_in_file); \r
}\r
else\r
annots->read_tail_ok_flag=1;\r
free(checkEOF);\r
}\r
+ \r
fclose(annot_in_file);\r
return annots;\r
}\r
/*\r
annotations.h\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
#define ANNOT_RECOS_TEXT 24\r
#define ANNOT_RECOS_LINENUMPOINTS 53\r
#define ANNOT_RECOS_LINEJOINFLAG 48\r
-#define ANNOT_RECOS_XSCALE 48\r
-#define ANNOT_RECOS_YSCALE 52\r
+#define ANNOT_RECOS_OVAL_POINTOS 136 // 24 for text + 4 + 11ints=44 + 1double=8 + 5pts=60\r
\r
// + 12*NUM POINTS\r
#define LINE_REC_LEN_V3 57\r
#define LINE_REC_LEN_V4 61 //???\r
\r
-\r
-//#define ANNOT_TYPE_LINE 0\r
-//#define ANNOT_TYPE_OVAL 1\r
-//#define ANNOT_TYPE_TEXT 2\r
-//#define ANNOT_TYPE_CIRCLE 3\r
-\r
-/*\r
-typedef struct annotations_file_head\r
+struct f_annotations_file_head\r
{\r
// always 0x2d001234\r
unsigned int uiunkn0;\r
unsigned int version;\r
// number of annotations in the stream\r
unsigned int c_annots;\r
-} tag_annotations_file_head;\r
- \r
-typedef struct annotation_record_header\r
-{\r
- // 0 = line\r
- // 1 = Oval\r
- // 2 = Textbox/Rectangle\r
- // 3 = Circle\r
- unsigned int type;\r
- // 0x8 = show length\r
- // 0x10 = order before roads\r
- // (order defore other objects depends on file order (last highest) and obj type)\r
- unsigned int bitflags;\r
- int iunkn0;\r
- int iunkn1;\r
- // iunkn2 is only for version 10+ (9+?)\r
- int iunkn2;\r
- unsigned int text_len;\r
- char text[];\r
- // 0 =black\r
- // 12=blue\r
- unsigned int fill_color;\r
- // 0 = none\r
- // 1 = fill\r
- // + some other high-byte flags?\r
- int fill_flag;\r
- // 0 = black\r
- // 12 = blue\r
- // 0d = yellow\r
- unsigned int line color;\r
- // 20*point size \r
- unsigned int line_width;\r
- // 00=none, \r
- // 01=left, \r
- // 02=right, \r
- // 03=both;\r
- int arrow_type;\r
- int iunkn3;\r
- // 01 is a joined line: the first & last points are joined\r
- // 00 is a line-type\r
- int closed_flag;\r
- char cunkn0;\r
- // number of points in the line\r
- char c_line_points;\r
- struct point_rec[];\r
-} tag_annotation_header;\r
-\r
-struct annot_line_point\r
-{\r
- float x;\r
- float y;\r
- float z;\r
-}\r
-\r
-*/\r
+} ;\r
\r
-typedef struct annot_rec\r
+struct annot_rec\r
{\r
// ANNOT_TYPE_\r
int type;\r
int text_length;\r
char* text;\r
int line_points;\r
- // Pointer to the line-points data in buf, \r
+ // Pointer to the line-points data in buf,\r
// because it moves with different file formats.\r
int line_offset;\r
-} tag_annot_rec;\r
+ unsigned char is_closed_line_flag;\r
+};\r
\r
struct annot_rec * annot_rec_new();\r
void annot_rec_delete(struct annot_rec * annot_rec);\r
\r
-typedef struct annotations\r
+struct annotations\r
{\r
int num_annotations;\r
int max_annot_num;\r
int stream_length;\r
// This is the annotations version number, as stored in the annotations stream\r
int version;\r
-} tag_annotations;\r
+};\r
\r
struct annotations * annotations_new();\r
void annotations_delete(struct annotations * annots);\r
struct gpxpt* gpx_get_point(char* buf);\r
+//struct gpxpt* gpx_get_point(struct annot_line_point* bufpt);\r
\r
extern char std_annotfile_header[ANNOT_FILE_HEAD_LEN];\r
extern char std_annot_linerec_header_v3[LINE_REC_LEN_V3];\r
\r
struct annotations * process_annotations_stream(char* annot_in_file_name);\r
\r
-\r
#ifdef __cplusplus\r
}\r
#endif\r
but "steph's wedding.est" is ok (single space)\r
\r
with input file "Plesivec - Ple\9aivec.gpx" we fail to open the gpx as input\r
+ \r
+ exception importing gpx with long descriptions\r
+ mp2004 imported ppins: dont show info, accessing ballon property crashes mp\r
\r
/*\r
contents.c\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
#include "contents.h"\r
#include "annotations.h"\r
\r
-char* buf2str(char* buf, int strlen)\r
-// make a null-terminated string from a buf\r
-{\r
- char*str=NULL;\r
- if (strlen==0)\r
- return NULL;\r
- str=(char*)xmalloc(strlen+1);\r
- memcpy(str, buf, strlen);\r
- str[strlen]=0;\r
- return str;\r
-}\r
+#ifdef EXPLORE\r
+#include "explore.h"\r
+#endif\r
\r
struct contents * contents_new()\r
{\r
nw->fully_parsed_flag=0;\r
nw->buf_len=0;\r
nw->buf=NULL;\r
- nw->f_conts0=NULL;\r
- nw->f_conts_array=NULL;\r
+ nw->conts0_os=0;\r
+//x nw->f_conts0=NULL;\r
+ nw->array_os=0;\r
+//x nw->f_conts_array=NULL;\r
nw->f_pcbtext0=NULL;\r
nw->f_text0=NULL;\r
- nw->f_conts1=NULL;\r
+ nw->conts1_os=0;\r
+//x nw->f_conts1=NULL;\r
nw->f_text1=NULL;\r
- nw->f_conts2=NULL;\r
+ nw->conts2_os=0;\r
+//x nw->f_conts2=NULL;\r
// conts2->count_strings strings.\r
// Strings are not nul-terminated,\r
// but they are prefixed with their length.\r
nw->list_f_pcbtext=NULL;\r
nw->list_f_text=NULL;\r
- nw->f_conts3=NULL;\r
+ nw->conts3_os=0;\r
+//x nw->f_conts3=NULL;\r
// the end part of the buffer that has not been interpreted.\r
nw->rest=NULL;\r
return nw;\r
free(conts);\r
}\r
\r
-void print_f_contents0(struct f_contents0 * conts)\r
-{\r
- struct gpxpt* map_cent=NULL;\r
-\r
- printf("struct f_contents1:\n");\r
- printf("usunkn0=%d\n", conts->usunkn0);\r
- printf("map_center_X=%f\n", conts->map_center_X);\r
- printf("map_center_Y=%f\n", conts->map_center_Y);\r
- printf("map_center_Z=%f\n", conts->map_center_Z);\r
- printf("map_scale=%f\n", conts->map_scale);\r
- printf("iunkn0=%d\n", conts->iunkn0);\r
- printf("iunkn1=%d\n", conts->iunkn1);\r
- printf("iunkn2=%d\n", conts->iunkn2);\r
- printf("iunkn3=%d\n", conts->iunkn3);\r
- printf("iunkn4=%d\n", conts->iunkn4);\r
- printf("iunkn5=%d\n", conts->iunkn5);\r
- printf("iunkn6=%d\n", conts->iunkn6);\r
- printf("legend_or_directions=%d\n", conts->legend_or_directions);\r
- printf("iunkn7=%d\n", conts->iunkn7);\r
- printf("iunkn8=%d\n", conts->iunkn8);\r
- printf("iunkn9=%d\n", conts->iunkn9);\r
- printf("usunkn2=%d\n", conts->usunkn2);\r
- printf("iunkn10=%d\n", conts->iunkn10);\r
- printf("iunkn11=%d\n", conts->iunkn11);\r
- debug_pause();\r
- printf("iunkn12=%d\n", conts->iunkn12);\r
- printf("iunkn13=%d\n", conts->iunkn13);\r
- printf("map_format_pannels=%d\n", conts->map_format_pannels);\r
- printf("iunkn14=%d\n", conts->iunkn14);\r
- printf("map_format_style=%d\n", conts->map_format_style);\r
- printf("iunkn16=%d\n", conts->iunkn16);\r
- printf("map_format_font_size=%d\n", conts->map_format_font_size);\r
-\r
- printf("usunkn4=%d\n", conts->usunkn4);\r
- printf("section_len=%d\n", conts->section_len);\r
- printf("usunkn5=%d\n", conts->usunkn5);\r
- printf("array_len=%d\n", conts->array_len);\r
-\r
- map_cent = gpx_get_point((char*)(&conts->map_center_X));\r
- printf("Got map center %f %f with scale %f (km?).\n",\r
- map_cent->lat, map_cent->lon, conts->map_scale);\r
- gpxpt_delete(map_cent);\r
-\r
- printf("\n");\r
- printf("\n");\r
- debug_pause();\r
-}\r
-/* contents_array\r
- printf("usunkn6=%d\n", conts->usunkn6);\r
- printf("usunkn7=%d\n", conts->usunkn7);\r
- printf("usunkn8=%d\n", conts->usunkn8);\r
- printf("usunkn9=%d\n", conts->usunkn9);\r
- printf("LastSetId=%d\n", conts->LastSetId);\r
- printf("iunkn18=%d\n", conts->iunkn18);\r
- printf("usunkn10=%d\n", conts->usunkn10);\r
- printf("iunkn19=%d\n", conts->iunkn19);\r
- printf("usunkn11=%d\n", conts->usunkn11);\r
- printf("cbText0=%d\n", conts->cbText0);\r
-*/\r
-\r
-void print_f_contents1(struct f_contents1 * conts)\r
-{\r
- printf("struct f_contents1:\n");\r
-\r
- printf("iunkn20=%d\n", conts->iunkn20);\r
- printf("cbText1=%d\n", conts->cbText1);\r
-\r
- printf("\n");\r
- debug_pause();\r
-}\r
-\r
-void print_f_contents2(struct f_contents2 * conts)\r
-{\r
- printf("struct f_contents1:\n");\r
-\r
- printf("iunkn21=%d\n", conts->iunkn21);\r
- printf("count_strings=%d\n", conts->count_strings);\r
-\r
- printf("\n");\r
- debug_pause();\r
-}\r
-\r
-void print_f_contents3(struct f_contents3 * conts)\r
-{\r
- printf("struct f_contents3:\n");\r
-\r
- printf("usunkn15=%d\n", conts->usunkn15);\r
- printf("usunkn16=%d\n", conts->usunkn16);\r
- printf("usunkn17=%d\n", conts->usunkn17);\r
- printf("usunkn18=%d\n", conts->usunkn18);\r
- printf("cbCountryText=%d\n", conts->cbCountryText);\r
-\r
- printf("\n");\r
- debug_pause();\r
-}\r
-\r
struct contents * parse_contents_buffer(char* buf, unsigned int buf_len)\r
{\r
struct contents * conts = contents_new();\r
unsigned int buf_pos=0;\r
- char* temp_str;\r
unsigned int i;\r
+ unsigned int numstrings;\r
\r
conts->buf = buf;\r
conts->buf_len=buf_len;\r
// Parse f_contents0\r
// *****************\r
\r
- conts->f_conts0 = (struct f_contents0 *)(conts->buf);\r
- buf_pos += sizeof(struct f_contents0);\r
+ //x conts->f_conts0 = (struct f_contents0 *)(conts->buf);\r
+ conts->conts0_os=0;\r
+ //x buf_pos += sizeof(struct f_contents0);\r
+ buf_pos += CONT_RECSZ_C0;\r
+\r
if (buf_pos>(conts->buf_len))\r
{\r
printf("Oops, ran out of buffer with conts0.\n");\r
return conts;\r
}\r
- if(opts.explore_flag)\r
- print_f_contents0(conts->f_conts0);\r
-\r
// **************************\r
// Parse conts->f_conts_array\r
// **************************\r
\r
- conts->f_conts_array=(unsigned short *)(conts->buf + buf_pos);\r
- buf_pos += conts->f_conts0->array_len;\r
+ //conts->f_conts_array=(unsigned short *)(conts->buf + buf_pos);\r
+ conts->array_os=buf_pos;\r
+ //buf_pos += conts->f_conts0->array_len;\r
+ buf_pos += *(unsigned int*)(conts->buf + CONT_RECOS_ARRAY_LEN);\r
if (buf_pos>(conts->buf_len))\r
{\r
printf("Oops, ran out of buffer with conts array.\n");\r
return conts;\r
}\r
- if(opts.explore_flag)\r
- {\r
- printf("Dumping Contents array:\n");\r
- printbuf((char*)(conts->f_conts_array), conts->f_conts0->array_len);\r
-\r
- for(i=0; i< 3; i++)\r
- printf("Array[%d]=%d - unknown meaning\n", i, conts->f_conts_array[i]);\r
-\r
- printf("n:=Array[3]=%d is number of user pushpin sets\n", (conts->f_conts_array)[3]);\r
-\r
-// for(i=0; i< (conts->f_conts_array[3]); i++)\r
-// printf("Array[%d]=%d is SetId for user PushpinSet[%d] \n",\r
-// 4+i,\r
-// conts->f_conts_array[4+i],\r
-// conts->f_conts_array[3] - i -1);\r
-\r
- for(i=0; i< (conts->f_conts_array[3]); i++)\r
- printf("Array[4+n-(%d)]=%d is SetId for user PushpinSet[%d]\n",\r
- i, conts->f_conts_array[3+(conts->f_conts_array[3])-i], i);\r
-\r
- for(i=0; (4 + (conts->f_conts_array[3] +i)) < (conts->f_conts0->array_len)/2 ; i++)\r
- printf("Array[5+n+(%d)]=%d - unknown meaning\n",\r
- i, conts->f_conts_array[4+(conts->f_conts_array[3])+i]);\r
-\r
- debug_pause();\r
-\r
-// printf("Dumping Contents array tail:\n");\r
-// printbuf((char*)(conts->f_conts_array + 4 + conts->f_conts_array[3]),\r
-// (conts->f_conts0->array_len)-2*(4 + conts->f_conts_array[3]) );\r
- }\r
\r
// ************************\r
// Parse f_cbtext0, f_text0\r
printf("Oops, ran out of buffer with text0.\n");\r
return conts;\r
}\r
- // conts->f_cbtext0 is a *pointer* to text len\r
- if(opts.explore_flag)\r
- {\r
- temp_str=buf2str(conts->f_text0, *(conts->f_pcbtext0));\r
- printf("Got Text0='%s'\n", temp_str);\r
- free(temp_str);\r
- temp_str=NULL;\r
- }\r
\r
// *****************\r
// Parse f_contents1\r
// *****************\r
\r
- conts->f_conts1 = (struct f_contents1 *)(conts->buf+buf_pos);\r
- buf_pos += sizeof(struct f_contents1);\r
+ //x conts->f_conts1 = (struct f_contents1 *)(conts->buf+buf_pos);\r
+ conts->conts1_os = buf_pos;\r
+ //buf_pos += sizeof(struct f_contents1);\r
+ buf_pos += CONT_RECSZ_C1;\r
if (buf_pos>(conts->buf_len))\r
{\r
printf("Oops, ran out of buffer with conts1.\n");\r
return conts;\r
}\r
- if(opts.explore_flag)\r
- print_f_contents1(conts->f_conts1);\r
\r
// *************\r
// Parse f_text1\r
// *************\r
\r
conts->f_text1 = (conts->buf)+buf_pos;\r
- buf_pos += conts->f_conts1->cbText1;\r
+ //x buf_pos += conts->f_conts1->cbText1;\r
+ buf_pos += *(unsigned char *)((conts->buf)+buf_pos-1);\r
if (buf_pos>(conts->buf_len))\r
{\r
printf("Oops, ran out of buffer with text1.\n");\r
return conts;\r
}\r
- if(opts.explore_flag)\r
- {\r
- temp_str=buf2str(conts->f_text1, conts->f_conts1->cbText1);\r
- printf("Got Text1='%s'\n", temp_str);\r
- free(temp_str);\r
- temp_str=NULL;\r
- }\r
\r
// *****************\r
// Parse f_contents2\r
// *****************\r
\r
- conts->f_conts2 = (struct f_contents2 *)((conts->buf)+buf_pos);\r
- buf_pos += sizeof(struct f_contents2);\r
+ //x conts->f_conts2 = (struct f_contents2 *)((conts->buf)+buf_pos);\r
+ conts->conts2_os = buf_pos;\r
+ //x buf_pos += sizeof(struct f_contents2);\r
+ buf_pos += CONT_RECSZ_C2;\r
if (buf_pos>(conts->buf_len))\r
{\r
printf("Oops, ran out of buffer with conts2.\n");\r
return conts;\r
}\r
- if(opts.explore_flag)\r
- print_f_contents2(conts->f_conts2);\r
\r
// ***************************************\r
// Parse list_f_cbtext[] and list_f_text[]\r
// ***************************************\r
\r
- conts->list_f_pcbtext=(unsigned char**)xmalloc((conts->f_conts2->count_strings)*sizeof(unsigned char*));\r
- conts->list_f_text=(char**)xmalloc((conts->f_conts2->count_strings)*sizeof(char*));\r
+ numstrings = *(unsigned short*)(conts->buf + conts->conts2_os + 4);\r
+ //x numstrings = conts->f_conts2->count_strings;\r
+ conts->list_f_pcbtext=(unsigned char**)xmalloc(numstrings*sizeof(unsigned char*));\r
+ conts->list_f_text=(char**)xmalloc(numstrings*sizeof(char*));\r
// initialise just incase we dont make it through the parse loop\r
- for(i=0; i<(conts->f_conts2->count_strings); i++)\r
+ for(i=0; i<numstrings; i++)\r
{\r
conts->list_f_pcbtext[i]=NULL;\r
conts->list_f_text[i]=NULL;\r
}\r
- for(i=0; i<(conts->f_conts2->count_strings); i++)\r
+ for(i=0; i<numstrings; i++)\r
{\r
// list_f_cbtext[i] is a *pointer* to text len\r
conts->list_f_pcbtext[i]=(unsigned char*)(conts->buf+buf_pos);\r
printf("Oops, ran out of buffer with text%d.\n", i);\r
return conts;\r
}\r
- if(opts.explore_flag)\r
- {\r
- temp_str = buf2str(conts->list_f_text[i], *(conts->list_f_pcbtext[i]));\r
- printf("Got list_text[%d]='%s'\n", i, temp_str);\r
- free(temp_str);\r
- }\r
}\r
\r
// **************************\r
printf("Oops, ran out of buffer with pusunkn0.\n");\r
return conts;\r
}\r
- if(opts.explore_flag)\r
- printf("usunkn0=%d\n", *(conts->pusunkn0) );\r
\r
if(*(conts->pusunkn0) == 1)\r
{\r
printf("Oops, ran out of buffer with piunkn1.\n");\r
return conts;\r
}\r
- if(opts.explore_flag)\r
- printf("iunkn1=%d\n", *(conts->piunkn1) );\r
}\r
\r
// *****************\r
- // Parse f_contents2\r
+ // Parse f_contents3\r
// *****************\r
\r
- conts->f_conts3 = (struct f_contents3 *)(conts->buf+buf_pos);\r
- buf_pos += sizeof(struct f_contents3);\r
+ //x conts->f_conts3 = (struct f_contents3 *)(conts->buf+buf_pos);\r
+ conts->conts3_os = buf_pos;\r
+ //x buf_pos += sizeof(struct f_contents3);\r
+ buf_pos += CONT_RECSZ_C3;\r
if (buf_pos>(conts->buf_len))\r
{\r
printf("Oops, ran out of buffer with conts3.\n");\r
return conts;\r
}\r
- if(opts.explore_flag)\r
- print_f_contents3(conts->f_conts3);\r
\r
// *****************\r
// Parse CountryText\r
// *****************\r
\r
conts->CountryText = (conts->buf)+buf_pos;\r
- buf_pos += conts->f_conts3->cbCountryText;\r
+ //x buf_pos += conts->f_conts3->cbCountryText;\r
+ buf_pos += *(unsigned char *)((conts->buf)+buf_pos-1);\r
if (buf_pos>(conts->buf_len))\r
{\r
- printf("Oops, ran out of buffer with text[%d].\n", conts->f_conts2->count_strings);\r
+ printf("Oops, ran out of buffer with country text.\n");\r
return conts;\r
}\r
- if(opts.explore_flag)\r
- {\r
- temp_str=buf2str(conts->CountryText, conts->f_conts3->cbCountryText);\r
- if(opts.explore_flag)\r
- printf("Got CountryText='%s'\n", temp_str);\r
- free(temp_str);\r
- temp_str=NULL;\r
- }\r
\r
if (buf_pos == conts->buf_len)\r
conts->fully_parsed_flag=1;\r
{\r
printf("Unexpected %d bytes of contents buffer still remaining.\n",\r
(conts->buf_len)-buf_pos);\r
- printbuf((conts->buf)+buf_pos, (conts->buf_len)-buf_pos);\r
+ if(opts.verbose_flag > 4)\r
+ printbuf((conts->buf)+buf_pos, (conts->buf_len)-buf_pos);\r
}\r
\r
+#ifdef EXPLORE\r
+ if (opts.explore_flag)\r
+ print_contents(conts);\r
+#endif\r
+\r
return conts;\r
}\r
\r
if ((conts_file = fopen(conts_file_name, "rb")) == NULL)\r
{\r
fprintf(stderr, "Cannot open property file %s\n", conts_file_name);\r
- return NULL;\r
+ debug_pause();\r
+ exit(3);\r
+ //return NULL;\r
}\r
\r
if ((readbyte = getc(conts_file))!=EOF)\r
}\r
fclose(conts_file);\r
\r
- printf("Read %d bytes in contents stream %s\n", buf_pos, conts_file_name);\r
+ if (opts.verbose_flag>2)\r
+ printf("Read %d bytes in contents stream %s\n", buf_pos, conts_file_name);\r
if (opts.verbose_flag>4)\r
{\r
printbuf(buf, buf_pos);\r
nw_buf = (char *)xmalloc(nw_buf_len);\r
\r
// insert after f_conts_array[3], ie at f_conts_array+4\r
- insert_position = ((char*)(old_conts->f_conts_array+4)-(old_conts->buf));\r
+ //x insert_position = ((char*)(old_conts->f_conts_array+4)-(old_conts->buf));\r
+ insert_position = old_conts->array_os + 8;\r
\r
memcpy(nw_buf, old_conts->buf, insert_position);\r
memcpy(nw_buf + insert_position, &newSetId, sizeof(unsigned short));\r
old_conts->buf_len - insert_position);\r
\r
// set the size of the contents aray\r
- arraylen_os = (char*)&(old_conts->f_conts0->array_len) - old_conts->buf;\r
+ //x arraylen_os = (char*)&(old_conts->f_conts0->array_len) - old_conts->buf;\r
+ arraylen_os = old_conts->array_os - 4;\r
*(nw_buf + arraylen_os) += sizeof(unsigned short);\r
\r
// increase the number of pushpin sets in f_conts_array[3]\r
*(nw_buf + insert_position - sizeof(unsigned short)) +=1;\r
\r
+ // increase section length\r
+ *(nw_buf + CONT_RECOS_SECT_LEN) +=2;\r
+ // increase iunkn20\r
+ // *(int*)(nw_buf + old_conts->conts1_os + 2) +=1;\r
+\r
nw_conts=parse_contents_buffer(nw_buf, nw_buf_len);\r
\r
return nw_conts;\r
printf("Wrote %d bytes to new contents stream in %s\n", conts->buf_len, conts_file_name);\r
\r
fclose(conts_out_file);\r
-\r
}
\ No newline at end of file
/*\r
contents.h\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
extern "C" {\r
#endif\r
\r
-typedef struct f_contents0\r
-{\r
- // @ 00\r
- unsigned short usunkn0; // 0c 00\r
- float map_center_X;\r
- float map_center_Y;\r
- float map_center_Z;\r
- // in km?\r
- float map_scale;\r
- // @ 12\r
- int iunkn0; // 00 00 00 00\r
- // next two are interesting when there are ppins imported from a file\r
- // got 180213657 = ABDD799\r
- // and -1073143305 = C00921F7\r
- int iunkn1;\r
- int iunkn2;\r
- int iunkn3; // 20 03 00 00\r
- // @ 22\r
- int iunkn4; // 01 00 00 00\r
- int iunkn5; // 06 00 00 00\r
- int iunkn6; // c4 09 00 00\r
- // 0=legend/route directions if\r
- // 1=no legend\r
- // (related to iunkn13)\r
- unsigned short legend_or_directions; // 00 00 / 01 00\r
- // @ 30\r
- int iunkn7; // 01 00 00 00\r
- int iunkn8; // 06 00 00 00\r
- int iunkn9; // e4 0c 00 00 for eur8, c4 09 00 00 for usa9\r
- unsigned short usunkn2; // 00 00\r
- int iunkn10; // 1\r
- // @ 42\r
- int iunkn11; // 06 00 00 00\r
- int iunkn12; // XX XX 00 00\r
- unsigned short iunkn13; // 00 00\r
-\r
- // Does not seem to match these values...\r
- //GeoPaneState Value Description \r
- //geoPaneLegend 0 Legend is displayed \r
- //geoPaneNearbyPlaces 2 Find Nearby Places pane is displayed \r
- //geoPaneNone 3 Only the map is displayed \r
- //geoPaneRoutePlanner 1 Route Planner pane is displayed \r
- //geoPaneTerritory 4 Territory Manager pane is displayed \r
-\r
- // 0=no legend or show route directions ( iunkn6)\r
- // 1=normal\r
- // 2=route planner\r
- // 4=find nearby places\r
- int map_format_pannels;\r
- // @ 50\r
- int iunkn14; // 1 0 4 0\r
-\r
-// GeoMapStyle Value Description \r
-// geoMapStyleData 2 Data map \r
-// geoMapStylePolitical 4 Political map \r
-// geoMapStyleRoad 0 Road map \r
-// geoMapStyleRoadData 1 Road and data map \r
-// geoMapStyleTerrain 3 Terrain map \r
- \r
- // 0 = Road\r
- // 3 = Terrain\r
- // 4 = Political\r
- int map_format_style;\r
- int iunkn16; // 1 0 4 0\r
- // 0-4,\r
- // 0=largest\r
- // 4=smallest\r
- int map_format_font_size; // 03 00 00 00\r
- // @ 60\r
- unsigned short usunkn4; //03 00\r
- //length of section from here until end of EUR/USA string\r
- int section_len;\r
- unsigned short usunkn5; // 03 00\r
- // array_len = 0x14 + 2*num ppin sets\r
- // if array_len=0x14, str1@81. if array_len=0x16 str1@83\r
- unsigned int array_len; // xx 00 00 00 (14/16)\r
-} tag_f_contents0;\r
-\r
-/*\r
-typedef struct f_contents_array\r
-{\r
- unsigned short usunkn6; // 03 00\r
- unsigned short usunkn7; // 02/01 00\r
- // @ 70\r
- unsigned short usunkn8; // 00 00\r
- // number of user ppin sets\r
- unsigned short usunkn9; // 00/01 00 (0 for empty, 1 for ppins?)\r
- // from UserData/GEODB_LastId/LastSetId\r
- // note the size mismatch: short/long\r
- unsigned short LastSetId;\r
- unsigned short usunkn9_1; // 0\r
- unsigned short usunkn9_2; // 0\r
- unsigned short usunkn10; // 0\r
- unsigned short usunkn10_1; // 0\r
- unsigned short usunkn10_2; // 0\r
- int iunkn19; // 3\r
- // @ 80\r
- unsigned short usunkn11; // 0\r
-} tag_f_contents_array;\r
-*/\r
-\r
-// + unsigned char cbText0;\r
-// + cbText0 bytes of text\r
-\r
-// @ 8b\r
-\r
-typedef struct f_contents1\r
-{\r
- int iunkn20; // 00 00 00 00/ff ff ff ff\r
- unsigned char cbText1;\r
-} tag_f_contents1;\r
-\r
-// + cbText1 bytes of text\r
-// @ 98\r
-typedef struct f_contents2\r
-{\r
- int iunkn21; // ff ff ff ff\r
- // This is a count of strings before contents3\r
- unsigned short count_strings; // 3\r
-} tag_f_contents2;\r
-\r
-// unsigned char cbText2;\r
-// + cbText2 bytes of text\r
-// @ a6\r
-// + unsigned char cbText3\r
-// + cbText3 bytes of text\r
-// @ ae\r
-// + optional ? unsigned char cbText4\r
-// + optional ? cbText4 bytes of text\r
-// @ b7\r
-\r
-//+ unsigned short usunkn14;\r
-// + int (if usunkn14)\r
-\r
-typedef struct f_contents3\r
-{\r
- unsigned short usunkn15;\r
- unsigned short usunkn16;\r
- unsigned short usunkn17;\r
- unsigned short usunkn18;\r
- // FIXME + an extra short for usa9, + 2 extra shorts for usa10\r
- unsigned char cbCountryText;\r
-} tag_f_contents3;\r
-\r
-// + cbText5 bytes of text: USA/EUR\r
-\r
-// more for USA9\r
-// + int\r
-// + unsigned char cbText6\r
-// + cbText6 bytes of text\r
-// + unsigned char cbText7\r
-// + cbText7 bytes of text : path to html: html export file?\r
-// + 0x40 bytes\r
+#define CONT_RECSZ_C0 108\r
+#define CONT_RECOS_SECT_LEN 98\r
+#define CONT_RECOS_ARRAY_LEN 104\r
+#define CONT_RECSZ_C1 5\r
+#define CONT_RECSZ_C2 6\r
+#define CONT_RECSZ_C3 9\r
\r
\r
-typedef struct contents\r
+struct contents\r
{\r
int fully_parsed_flag;\r
unsigned int buf_len;\r
// The data as read from the contents stream.\r
char* buf;\r
- struct f_contents0 * f_conts0;\r
- unsigned short * f_conts_array;\r
+ int conts0_os;\r
+ //x struct f_contents0 * f_conts0;\r
+ int array_os;\r
+ //x unsigned short * f_conts_array;\r
unsigned char * f_pcbtext0;\r
char* f_text0;\r
- struct f_contents1 * f_conts1;\r
+ int conts1_os;\r
+ //x struct f_contents1 * f_conts1;\r
char* f_text1;\r
- struct f_contents2 * f_conts2;\r
+ int conts2_os;\r
+ //x struct f_contents2 * f_conts2;\r
// Lengths for conts2->count_strings number of strings.\r
// Note that this is array of *pointers* to string-length\r
unsigned char ** list_f_pcbtext;\r
unsigned short * pusunkn0;\r
// Only when usunkn0=1 ???\r
int * piunkn1;\r
- struct f_contents3 * f_conts3;\r
+ int conts3_os;\r
+ //x struct f_contents3 * f_conts3;\r
char * CountryText;\r
// The end part of the buffer that has not been interpreted.\r
char* rest;\r
-} tag_contents;\r
+} ;\r
\r
struct contents * read_contents(char* conts_file_name);\r
struct contents * contents_insert_ppinset(struct contents * old_conts, unsigned short newSetId);\r
/*\r
debug.c\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
printf("\n\n");\r
}\r
\r
-void printpoints(char* buf, int numpts)\r
-{\r
- int i;\r
- struct gpxpt* pt;\r
- printf("Latitude Longitude Height");\r
- printf("\n");\r
- printf("--------------------------\n");\r
- for(i=0; i<numpts; i++)\r
- {\r
- pt = gpx_get_point(buf + 12*i);\r
- printf("%f %f %f \n",pt->lat, pt->lon, pt->elevation);\r
- gpxpt_delete(pt);\r
- }\r
- printf("\n\n");\r
-}\r
-\r
-void explore_annot(struct annot_rec * rec)\r
-{\r
-}\r
-\r
-void print_f_jour_header(struct f_jour_header * head)\r
-{\r
- printf("struct f_jour_header:\n");\r
- printf("iunkn0 %x=%d\n", head->iunkn0, head->iunkn0);\r
- printf("iunkn1 %x=%d\n", head->iunkn1, head->iunkn1);\r
- printf("iunkn2 %x=%d\n", head->iunkn2, head->iunkn2);\r
- printf("iunkn3 %x=%d\n", head->iunkn3, head->iunkn3);\r
- printf("cpoints %x=%d\n", head->cpoints, head->cpoints);\r
- printf("iunkn4 %x=%d\n", head->iunkn4, head->iunkn4);\r
- printf("iunkn5 %x=%d\n", head->iunkn5, head->iunkn5);\r
- printf("iunkn6 %x=%d\n", head->iunkn6, head->iunkn6);\r
-}\r
-\r
-void print_f_jour_pt_head(struct f_jour_pt_head * pt_head)\r
-{\r
-// double x;\r
- printf("struct f_jour_pt_head:\n");\r
- printf("UdId %d\n", pt_head->UdId);\r
- printf("stop_dur_secs %d\n", pt_head->stop_dur_secs);\r
- printf("iunkn0 %#x=%d\n", pt_head->iunkn0, pt_head->iunkn0);\r
- printf("sched_arrive_flag %d\n", pt_head->sched_arrive_flag);\r
- printf("sched_depart_flag %d\n", pt_head->sched_depart_flag);\r
- printf("arrive_time_secs %d\n", pt_head->arrive_time_secs);\r
- printf("depart_time_secs %d\n", pt_head->depart_time_secs);\r
- printf("iunkn1 %#x=%d\n", pt_head->iunkn1, pt_head->iunkn1);\r
-// x = pt_head->unkn_scaled_lon;\r
-// x = x*360/0x10000;\r
-// x = x/0x10000;\r
- printf("scaled_lon %d gives lon %f\n",\r
- pt_head->scaled_lon, scaled2deg(pt_head->scaled_lon));\r
-// x = (pt_head->unkn_scaled_lat*360/0x10000);\r
-// x = x/0x10000;\r
- printf("scaled_lat %d gives lat %f\n",\r
- pt_head->scaled_lat, scaled2deg(pt_head->scaled_lat));\r
- printf("cbtext1 %d\n",pt_head->cbtext1);\r
- printbuf((char*)pt_head, sizeof(struct f_jour_pt_head));\r
-}\r
-\r
-void print_f_jour_pt_tail(struct f_jour_pt_tail * pt_tail)\r
-{\r
- printf("struct f_jour_pt_tail: \n");\r
- printf("route_rd_pref %x\n",pt_tail->route_rd_pref);\r
- printf("iunkn0 %x=%d\n", pt_tail->iunkn0, pt_tail->iunkn0);\r
- printf("iunkn1 %x=%d\n", pt_tail->iunkn1, pt_tail->iunkn1);\r
- printf("iunkn2 %x=%d\n", pt_tail->iunkn2, pt_tail->iunkn2);\r
- printf("iunkn3 %x=%d\n", pt_tail->iunkn3, pt_tail->iunkn3);\r
- printf("road_id %x=%d\n", pt_tail->road_id, pt_tail->road_id);\r
- printf("dist_along_rd_frac %lf \n", pt_tail->dist_along_rd_frac);\r
-\r
- printf("rd_arrive_sc_lat %d gives lat %f\n",\r
- pt_tail->rd_arrive_sc_lat, scaled2deg(pt_tail->rd_arrive_sc_lat));\r
-\r
- printf("rd_arrive_sc_lon %d gives lat %f\n",\r
- pt_tail->rd_arrive_sc_lon, scaled2deg(pt_tail->rd_arrive_sc_lon));\r
-\r
- printf("rd_depart_sc_lat %d gives lat %f\n",\r
- pt_tail->rd_depart_sc_lat, scaled2deg(pt_tail->rd_depart_sc_lat));\r
-\r
- printf("rd_depart_sc_lon %d gives lat %f\n",\r
- pt_tail->rd_depart_sc_lon, scaled2deg(pt_tail->rd_depart_sc_lon));\r
-\r
- printf("iunkn8 %x=%d\n", pt_tail->iunkn8, pt_tail->iunkn8);\r
- printf("iunkn9 %x=%d\n", pt_tail->iunkn9, pt_tail->iunkn9);\r
- printf("iunkn10 %x=%d\n", pt_tail->iunkn10, pt_tail->iunkn10);\r
- printf("iunkn11 %x=%d\n", pt_tail->iunkn11, pt_tail->iunkn11);\r
- printf("iunkn12 %x=%d\n", pt_tail->iunkn12, pt_tail->iunkn12);\r
- printf("iunkn13 %x=%d\n", pt_tail->iunkn13, pt_tail->iunkn13);\r
- printf("iunkn14 %x=%d\n", pt_tail->iunkn14, pt_tail->iunkn14);\r
-\r
- printbuf((char*)pt_tail, sizeof(struct f_jour_pt_tail));\r
-}\r
-\r
-void print_f_jour_opts(struct f_jour_opts * jopts)\r
-{\r
- printf("struct f_jour_opts:\n");\r
-\r
- printf("siunkn0 %d\n", jopts->siunkn0);\r
- printf("funkn0 %f\n", jopts->funkn0);\r
- printf("toll_rd_pref %lf\n", jopts->toll_rd_pref);\r
- printf("motorway_pref %lf\n", jopts->motorway_pref);\r
- printf("major_rd_pref %lf\n", jopts->major_rd_pref);\r
- printf("minor_rd_pref %lf\n", jopts->minor_rd_pref);\r
- printf("ferry_pref %lf\n", jopts->ferry_pref);\r
- printf("iunkn0 %d\n", jopts->iunkn0);\r
- printf("iunkn1 %d\n", jopts->iunkn1);\r
- printf("iunkn2 %d\n", jopts->iunkn2);\r
- printf("fuel_price %lf\n", jopts->fuel_price);\r
- printf("iunkn3 %d\n", jopts->iunkn3);\r
- printf("fuel_price_unit %d\n", jopts->fuel_price_unit);\r
- printf("iunkn4 %d\n", jopts->iunkn4);\r
- printf("tank_capacity %lf\n", jopts->tank_capacity);\r
- printf("tank_capacity_units %d\n", jopts->tank_capacity_units);\r
- printf("tank_start_level %lf\n", jopts->tank_start_level);\r
- printf("tank_warn_level %lf\n", jopts->tank_warn_level);\r
- printf("iunkn5 %d\n", jopts->iunkn5);\r
- printf("fuel_use_city %lf\n", jopts->fuel_use_city);\r
- printf("fuel_use_city_unit %d\n", jopts->fuel_use_city_unit);\r
- printf("iunkn6 %d\n", jopts->iunkn6);\r
- printf("fuel_use_mway %lf\n", jopts->fuel_use_mway);\r
- printf("fuel_use_mway_unit %d\n", jopts->fuel_use_mway_unit);\r
- printf("iunkn7 %d\n", jopts->iunkn7);\r
- printf("mway_speed %f\n", jopts->mway_speed);\r
- printf("mway_speed_unit %d\n", jopts->mway_speed_unit);\r
- printf("iunkn9 %d\n", jopts->iunkn9);\r
- printf("lim_acc_speed %f\n", jopts->lim_acc_speed);\r
- printf("lim_acc_speed_unit %d\n", jopts->lim_acc_speed_unit);\r
- printf("iunkn11 %d\n", jopts->iunkn11);\r
- printf("maj_rd_speed %f\n", jopts->maj_rd_speed);\r
- printf("maj_rd_speed_unit %d\n", jopts->maj_rd_speed_unit);\r
- printf("iunkn13 %d\n", jopts->iunkn13);\r
- printf("min_rd_speed %f\n", jopts->min_rd_speed);\r
- printf("min_rd_speed_unit %d\n", jopts->min_rd_speed_unit);\r
- printf("iunkn15 %d\n", jopts->iunkn15);\r
- printf("street_speed %f\n", jopts->street_speed);\r
- printf("street_speed_unit %d\n", jopts->street_speed_unit);\r
- printf("iunkn17 %d\n", jopts->iunkn17);\r
- printf("iunkn18 %d\n", jopts->iunkn18);\r
- printf("funkn1 %f\n", jopts->funkn1);\r
- printf("iunkn19 %d\n", jopts->iunkn19);\r
- printf("iunkn20 %d\n", jopts->iunkn20);\r
- printf("iunkn21 %d\n", jopts->iunkn21);\r
- printf("funkn2 %f\n", jopts->funkn2);\r
- printf("iunkn22 %d\n", jopts->iunkn22);\r
- printf("iunkn23 %d\n", jopts->iunkn23);\r
- printf("iunkn24 %d\n", jopts->iunkn24);\r
- printf("funkn3 %f\n", jopts->funkn3);\r
- printf("iunkn25 %d\n", jopts->iunkn25);\r
- printf("iunkn26 %d\n", jopts->iunkn26);\r
- printf("iunkn27 %d\n", jopts->iunkn27);\r
- printf("funkn4 %f\n", jopts->funkn4);\r
- printf("iunkn28 %d\n", jopts->iunkn28);\r
- printf("iunkn29 %d\n", jopts->iunkn29);\r
- printf("iunkn30 %d\n", jopts->iunkn30);\r
- printf("funkn5 %f\n", jopts->funkn5);\r
- printf("iunkn31 %d\n", jopts->iunkn31);\r
- printf("iunkn32 %d\n", jopts->iunkn32);\r
- printf("iunkn33 %d\n", jopts->iunkn33);\r
- printf("start_drv_hr %d\n", jopts->start_drv_hr);\r
- printf("start_drv_min %d\n", jopts->start_drv_min);\r
- printf("iunkn34 %d\n", jopts->iunkn34);\r
- printf("end_drv_hr %d\n", jopts->end_drv_hr);\r
- printf("end_drv_min %d\n", jopts->end_drv_min);\r
- printf("fuel_warn_flag %d\n", jopts->fuel_warn_flag);\r
- printf("iunkn35 %d\n", jopts->iunkn35);\r
- printf("fuel_fixed_rate_flag %d\n", jopts->fuel_fixed_rate_flag);\r
- printf("iunkn36 %d\n", jopts->iunkn36);\r
- printf("fuel_cost_dist %d\n", jopts->fuel_cost_dist);\r
- printf("route_flex_secs %d\n", jopts->route_flex_secs);\r
- printf("iunkn37 %d\n", jopts->iunkn37);\r
- printf("rest_flag %d\n", jopts->rest_flag);\r
- printf("rest_dur_secs %d\n", jopts->rest_dur_secs);\r
- printf("rest_interval_secs %d\n", jopts->rest_interval_secs);\r
-\r
- printbuf((char*)jopts, sizeof(struct f_jour_opts));\r
- printf("\n");\r
-}\r
-\r
-void print_f_jour_opts_EUR_8(struct f_jour_opts_EUR_8 * jopts)\r
-{\r
- printf("struct f_jour_opts_EUR_8:\n");\r
-\r
- printf("iunkn38 %d\n", jopts->iunkn38);\r
- printf("iunkn39 %d\n", jopts->iunkn39);\r
- printf("iunkn40 %d\n", jopts->iunkn40);\r
- printf("iunkn41 %d\n", jopts->iunkn41);\r
- printf("iunkn42 %d\n", jopts->iunkn42);\r
- printf("siunkn1 %d\n", jopts->siunkn1);\r
- printf("route_show_tm %d\n", jopts->route_show_tm);\r
- printf("route_show_dist %d\n", jopts->route_show_dist);\r
- printf("route_show_inst %d\n", jopts->route_show_inst);\r
- printf("route_show_for %d\n", jopts->route_show_for);\r
- printf("route_show_to %d\n", jopts->route_show_to);\r
- printf("route_show_font_size %d\n", jopts->route_show_font_size);\r
- printf("iunkn43 %d\n", jopts->iunkn43);\r
- printf("iunkn44 %d\n", jopts->iunkn44);\r
- printf("count_avoid_regions %d\n", jopts->count_avoid_regions);\r
-\r
- printbuf((char*)jopts, sizeof(struct f_jour_opts_EUR_8));\r
- printf("\n");\r
-}\r
-\r
-void print_f_jour_opts_EUR_10(struct f_jour_opts_EUR_10 * jopts)\r
-{\r
- printf("struct f_jour_opts_EUR_10:\n");\r
-\r
- printf("iunkn38 %d\n", jopts->iunkn38);\r
- printf("iunkn39 %d\n", jopts->iunkn39);\r
- printf("iunkn40 %d\n", jopts->iunkn40);\r
- printf("iunkn41 %d\n", jopts->iunkn41);\r
- printf("iunkn41 %d\n", jopts->iunkn42);\r
- printf("count_avoid_regions %d\n", jopts->count_avoid_regions);\r
-\r
- printbuf((char*)jopts, sizeof(struct f_jour_opts_EUR_10));\r
- printf("\n");\r
-}\r
-\r
-void print_f_jour_opts_USA_8(struct f_jour_opts_USA_8 * jopts)\r
-{\r
- printf("struct f_jour_opts_USA_8:\n");\r
-\r
- printf("iunkn38 %d\n", jopts->iunkn38);\r
- printf("iunkn39 %d\n", jopts->iunkn39);\r
- printf("iunkn40 %d\n", jopts->iunkn40);\r
- printf("iunkn41 %d\n", jopts->iunkn41);\r
- printf("iunkn42 %d\n", jopts->iunkn42);\r
- printf("siunkn1 %d\n", jopts->siunkn1);\r
- printf("iunkn43 %d\n", jopts->iunkn43);\r
- printf("iunkn44 %d\n", jopts->iunkn44);\r
- printf("iunkn45 %d\n", jopts->iunkn45);\r
- printf("iunkn46 %d\n", jopts->iunkn46);\r
- printf("iunkn47 %d\n", jopts->iunkn47);\r
- printf("iunkn48 %d\n", jopts->iunkn48);\r
- printf("iunkn49 %d\n", jopts->iunkn49);\r
- printf("count_avoid_regions %d\n", jopts->count_avoid_regions);\r
-\r
- printbuf((char*)jopts, sizeof(struct f_jour_opts_USA_8));\r
- printf("\n");\r
-}\r
-\r
-void print_f_jour_opts_USA_10(struct f_jour_opts_USA_10 * jopts)\r
-{\r
- printf("struct f_jour_opts_USA_10:\n");\r
-\r
- printf("iunkn38 %d\n", jopts->iunkn38);\r
- printf("iunkn39 %d\n", jopts->iunkn39);\r
- printf("iunkn40 %d\n", jopts->iunkn40);\r
- printf("iunkn41 %d\n", jopts->iunkn41);\r
- printf("iunkn42 %d\n", jopts->iunkn42);\r
- printf("siunkn1 %d\n", jopts->siunkn1);\r
- printf("iunkn43 %d\n", jopts->iunkn43);\r
- printf("iunkn44 %d\n", jopts->iunkn44);\r
- printf("count_avoid_regions %d\n", jopts->count_avoid_regions);\r
-\r
- printbuf((char*)jopts, sizeof(struct f_jour_opts_USA_10));\r
- printf("\n");\r
-}\r
-\r
-void print_f_jour_avoid(struct f_jour_avoid * avoid)\r
-{\r
- struct gpxpt * gpt = gpx_get_point((char*)avoid);\r
- struct point pt;\r
- printf("struct f_jour_avoid:\n");\r
-\r
- printf("x %f\n", avoid->x);\r
- printf("y %f\n", avoid->y);\r
- printf("z %f\n", avoid->z);\r
- printf("iunkn0 %d\n", avoid->iunkn0);\r
- printf("iunkn1 %d\n", avoid->iunkn1);\r
- printf("iunkn2 %d\n", avoid->iunkn2);\r
- printf("iunkn3 %d\n", avoid->iunkn3);\r
- printf("iunkn4 %d\n", avoid->iunkn4);\r
- printf("iunkn5 %d\n", avoid->iunkn5);\r
- printf("annot_num %d\n", avoid->annot_num);\r
- printf("x,y,z give lat %f and lon %f\n", gpt->lat, gpt->lon);\r
-\r
- pt = grid2latlon(avoid->iunkn1, avoid->iunkn2);\r
- printf("iunkn1, lunkn2 as grid, precision give lat %f and lon %f\n", pt.lat, pt.lon);\r
- pt = grid2latlon(avoid->iunkn2, avoid->iunkn3);\r
- printf("iunkn2, lunkn3 as grid, precision give lat %f and lon %f\n", pt.lat, pt.lon);\r
- pt = grid2latlon(avoid->iunkn3, avoid->iunkn4);\r
- printf("iunkn3, lunkn4 as grid, precision give lat %f and lon %f\n", pt.lat, pt.lon);\r
-\r
- printbuf((char*)avoid, sizeof(struct f_jour_avoid));\r
- printf("\n");\r
-}\r
-\r
-void print_f_jour_trailer(struct f_jour_trailer * trailer)\r
-{\r
- printf("struct f_jour_trailer:\n");\r
-\r
- printf("iunkn0 %d\n", trailer->iunkn0);\r
- printf("iunkn1 %d\n", trailer->iunkn1);\r
-\r
- printbuf((char*)trailer, sizeof(struct f_jour_trailer));\r
- printf("\n");\r
-}\r
-\r
-void print_annot_rec(struct annot_rec * rec)\r
-{\r
- int bit_flags = *(int*)(rec->buf + 8);\r
- char* rec_type = NULL;\r
-\r
- if (rec->type<4)\r
- rec_type =annot_type_name[rec->type];\r
-\r
- printf("Got annotation id %d, of type %s, %d line points",\r
- rec->annot_num, rec_type, rec->line_points);\r
- if(rec->text !=NULL)\r
- printf(" and text '%s'", rec->text);\r
- printf("\n");\r
- if (opts.verbose_flag > 4)\r
- printf("(type=%d) text length %d, bitflags %#x buf length %d\n",\r
- rec->type, rec->text_length, bit_flags, rec->length);\r
-}\r
-\r
-void print_annotations(struct annotations * annots)\r
-{\r
- int i;\r
- // This is only the main stuff\r
- printf("Annotations list, version=%d, num_annotations=%d, max_annot_num=%d, stream_length=%d\n",\r
- annots->version, annots->num_annotations,\r
- annots->max_annot_num, annots->stream_length);\r
-\r
- for(i=0; i<annots->num_annotations; i++)\r
- print_annot_rec(annots->annot_list[i]);\r
-}\r
\r
void debug_show_sizes()\r
{\r
/*\r
gpx.h\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
#define GPX_ELEM_TYPE_DESC 8\r
#define GPX_ELEM_TYPE_SRC 9\r
\r
-typedef struct gpxpt\r
+struct gpxpt\r
{\r
double lat;\r
double lon;\r
char* url;\r
char* urlname;\r
// more later\r
-} tag_gpxpt;\r
+};\r
\r
struct gpxpt * gpxpt_new();\r
void gpxpt_delete(struct gpxpt * pt);\r
struct gpxpt * gpxpt_copy(struct gpxpt * otherpt);\r
\r
-typedef struct gpxrte\r
+struct gpxrte\r
{\r
char* name;\r
struct gpxpt** rtept_list;\r
int rtept_list_count;\r
-} tag_gpxrte;\r
+};\r
\r
struct gpxrte * gpxrte_new();\r
void gpxrte_delete(struct gpxrte * rte);\r
\r
-typedef struct gpxtrk\r
+struct gpxtrk\r
{\r
struct gpxpt** trkpt_list;\r
int trkpt_list_count;\r
-} tag_gpxtrk;\r
+} ;\r
\r
struct gpxtrk * gpxtrk_new();\r
void gpxtrk_delete(struct gpxtrk * trk);\r
\r
-typedef struct gpx_data\r
+struct gpx_data\r
{\r
char* data_source_name;\r
struct gpxpt ** wpt_list;\r
int rte_list_count;\r
struct gpxtrk ** trk_list;\r
int trk_list_count;\r
-} tag_gpx_data;\r
+};\r
\r
struct gpx_data * gpx_data_new();\r
void gpx_data_delete(struct gpx_data * data);\r
28-11-2003 imports pushpins\r
imports lines to v3 annotations (2002+)\r
5-12-2003 imports/exports symbols, with custom GPX symbol names\r
+11-12-2003 support lines with text (e.g. drive-time regions)\r
+ translate closed-polygons for import/export\r
+ export circles & ovals\r
+ support long pushpin notes\r
+ import groundspeak types with different symbols\r
+ various minor fixes\r
+ general clean-up\r
/*\r
journey.c\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
#include "st2gpx.h"\r
#include "pushpins.h"\r
#include "ppinutil.h"\r
-\r
#include "journey.h"\r
\r
+#ifdef EXPLORE\r
+#include "explore.h"\r
+#endif\r
+\r
float scaled2deg(int scaled_deg)\r
// there must be a simple single line calc\r
{\r
nw->buf_len=0;\r
nw->buf=NULL;\r
\r
+ nw->count_rtepts=0;\r
nw->rtept_list=NULL;\r
nw->jopts_os=0;\r
nw->jopts_eur8_os=0;\r
nw->jopts_usa8_os=0;\r
nw->jopts_usa10_os=0;\r
+ nw->count_avoid_regions=0;\r
nw->avoid_os_list=NULL;\r
nw->trailer_os=0;\r
return nw;\r
struct f_jour_opts_USA_8* opts_usa8;\r
struct f_jour_opts_USA_10* opts_usa10;\r
\r
- printf("Processing Journey stream\n");\r
+ if (opts.verbose_flag>2)\r
+ printf("Processing Journey stream\n");\r
\r
if ((jour_in_file = fopen(jour_in_file_name, "rb")) == NULL)\r
{\r
fprintf(stderr, "Quitting because I cannot open %s\n", jour_in_file_name);\r
+ debug_pause();\r
exit(1);\r
}\r
\r
\r
printf("got Journey file header with %d waypoints\n", jour->count_rtepts);\r
debug_pause();\r
- if (opts.explore_flag)\r
- print_f_jour_header((struct f_jour_header*)(jour->buf + jour->header_os));\r
\r
// an array of jour_rtept\r
jour->rtept_list = (struct jour_rtept *)xmalloc(\r
}\r
jour->rtept_list[j].pthead_os=jour->buf_len;\r
jour->buf_len += bytes2read;\r
- if (opts.explore_flag)\r
- print_f_jour_pt_head((struct f_jour_pt_head*)\r
- (jour->buf + jour->rtept_list[j].pthead_os));\r
\r
// read pt text1\r
bytes2read=((struct f_jour_pt_head*)\r
\r
str2ascii(jour->rtept_list[j].text1);\r
}\r
- if (opts.explore_flag)\r
- printf("Got text1 %s\n", jour->rtept_list[j].text1);\r
\r
// read pt middle\r
bytes2read=sizeof(struct f_jour_pt_mid);\r
}\r
jour->rtept_list[j].ptmid_os=jour->buf_len;\r
jour->buf_len += bytes2read;\r
- if (opts.explore_flag)\r
- {\r
- printf("dumping jour->rtept_list[%d].ptmid:\n", j);\r
- printbuf(jour->buf + jour->rtept_list[j].ptmid_os, bytes2read);\r
- }\r
\r
// read pt text2\r
bytes2read=2*(((struct f_jour_pt_mid*)(jour->buf+jour->rtept_list[j].ptmid_os))->cbtext2);\r
jour->rtept_list[j].text2[bytes2read+1]=0;\r
jour->buf_len += bytes2read;\r
}\r
- if (opts.explore_flag)\r
- wprintf(L"Got text2 %s\n", jour->rtept_list[j].text2);\r
\r
// read pt tail\r
bytes2read=sizeof(struct f_jour_pt_tail);\r
}\r
jour->rtept_list[j].pttail_os=jour->buf_len;\r
jour->buf_len += bytes2read;\r
- if (opts.explore_flag)\r
- print_f_jour_pt_tail((struct f_jour_pt_tail*)(jour->buf +jour->rtept_list[j].pttail_os));\r
\r
pt_head = (struct f_jour_pt_head*)(jour->buf+jour->rtept_list[j].pthead_os);\r
// UdId= ((struct f_jour_pt_head*)(jour->buf+jour->rtept_list[j].pthead_os))->UdId;\r
}\r
jour->jopts_os=jour->buf_len;\r
jour->buf_len += bytes2read;\r
- if (opts.explore_flag)\r
- print_f_jour_opts((struct f_jour_opts*)(jour->buf + jour->jopts_os));\r
\r
// read file-version specific journey options\r
if( (opts.st_version_num==8) && (opts.isUSA==0))\r
jour->buf_len += bytes2read;\r
opts_eur8=(struct f_jour_opts_EUR_8*)(jour->buf + jour->jopts_eur8_os);\r
jour->count_avoid_regions = opts_eur8->count_avoid_regions;\r
- if (opts.explore_flag)\r
- print_f_jour_opts_EUR_8(opts_eur8);\r
}\r
else if( ( (opts.st_version_num==10) && (opts.isUSA==0) )\r
- || ( (opts.st_version_num==9) && (opts.isUSA==1) )\r
- || ( (opts.st_version_num==11) && (opts.isUSA==1) ))\r
+ || ( (opts.st_version_num==9) )\r
+ || ( (opts.st_version_num==11) ))\r
{\r
bytes2read=sizeof(struct f_jour_opts_EUR_10);\r
jour->buf=(char*)xrealloc(jour->buf, jour->buf_len+bytes2read);\r
jour->buf_len += bytes2read;\r
opts_eur10=(struct f_jour_opts_EUR_10*)(jour->buf + jour->jopts_eur10_os);\r
jour->count_avoid_regions = opts_eur10->count_avoid_regions;\r
- if (opts.explore_flag)\r
- print_f_jour_opts_EUR_10(opts_eur10);\r
}\r
else if( (opts.st_version_num==8) && (opts.isUSA) )\r
{\r
jour->buf_len += bytes2read;\r
opts_usa8=(struct f_jour_opts_USA_8*)(jour->buf + jour->jopts_usa8_os);\r
jour->count_avoid_regions = opts_usa8->count_avoid_regions;\r
- if (opts.explore_flag)\r
- print_f_jour_opts_USA_8(opts_usa8);\r
}\r
- else if( (opts.st_version_num==10) && (opts.isUSA) )\r
+ else if((opts.st_version_num==10) && (opts.isUSA) )\r
{\r
bytes2read=sizeof(struct f_jour_opts_USA_10);\r
jour->buf=(char*)xrealloc(jour->buf, jour->buf_len+bytes2read);\r
jour->buf_len += bytes2read;\r
opts_usa10=(struct f_jour_opts_USA_10*)(jour->buf + jour->jopts_usa10_os);\r
jour->count_avoid_regions = opts_usa10->count_avoid_regions;\r
- if (opts.explore_flag)\r
- print_f_jour_opts_USA_10(opts_usa10);\r
}\r
else\r
printf("I dont yet understand the structure of the Journey options for this file version.\n");\r
}\r
jour->avoid_os_list[j]= jour->buf_len;\r
jour->buf_len += bytes2read;\r
- if (opts.explore_flag)\r
- print_f_jour_avoid((struct f_jour_avoid*)(jour->buf + jour->avoid_os_list[j]));\r
}\r
}\r
\r
}\r
jour->trailer_os=jour->buf_len;\r
jour->buf_len += bytes2read;\r
- if (opts.explore_flag)\r
- print_f_jour_trailer((struct f_jour_trailer*)(jour->buf + jour->trailer_os));\r
\r
readmore=0;\r
if ((readbyte = getc(jour_in_file))!=EOF)\r
\r
fclose(jour_in_file);\r
\r
- printf("Finished processing Journey stream.\n");\r
+ if (opts.verbose_flag>2)\r
+ printf("Finished processing Journey stream.\n");\r
fflush(stdout);\r
\r
+#ifdef EXPLORE\r
+ if (opts.explore_flag)\r
+ print_journey(jour);\r
+#endif\r
+\r
return jour;\r
}\r
/*\r
journey.h\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
// * points located by address Vs by mouse Vs by pushpin\r
// * avoid areas\r
// * drag route\r
-typedef struct f_jour_header\r
+struct f_jour_header\r
{\r
int iunkn0;\r
int iunkn1;\r
int iunkn4;\r
int iunkn5;\r
int iunkn6;\r
-} tag_f_jour_header;\r
+};\r
\r
-typedef struct f_jour_pt_head\r
+struct f_jour_pt_head\r
{\r
// DB prim key for pushpin\r
// 0 if no pushpin\r
int scaled_lon;\r
int scaled_lat;\r
unsigned char cbtext1;\r
-} tag_f_jour_pt_head;\r
+};\r
\r
// then jour_pt_head.cbtext1 bytes of text\r
\r
-typedef struct f_jour_pt_mid\r
+struct f_jour_pt_mid\r
{\r
// this just seems to be a const FF FE FF\r
char mid_tag[3];\r
unsigned char cbtext2;\r
-} tag_f_jour_pt_mid;\r
+};\r
\r
// then 2*jour_pt_mid.cbtext2 bytes of wide text\r
\r
-typedef struct f_jour_pt_tail\r
+struct f_jour_pt_tail\r
{\r
// 0=fastest\r
// 1=shortest\r
int iunkn13; // 1\r
// ? size ?\r
int iunkn14; // 30\r
-} tag_f_jour_pt_tail;\r
+} ;\r
\r
-typedef struct f_jour_opts\r
+struct f_jour_opts\r
{\r
// @00\r
short int siunkn0;\r
// @166\r
int rest_dur_secs;\r
int rest_interval_secs;\r
-} tag_jour_opts;\r
+} ;\r
\r
-typedef struct f_jour_opts_EUR_8\r
+// 56 bytes\r
+ struct f_jour_opts_EUR_8\r
{\r
int iunkn38;\r
int iunkn39;\r
// not in usa version8\r
int iunkn44;\r
unsigned short int count_avoid_regions;\r
-} tag_f_jour_opts_EUR_8;\r
+} ;\r
\r
-// Also works for USA9 and USA11\r
-typedef struct f_jour_opts_EUR_10\r
+// 22 bytes\r
+// Also works for USA9 and USA11 - and EUR9, EUR11\r
+struct f_jour_opts_EUR_10\r
{\r
int iunkn38;\r
int iunkn39;\r
int iunkn42;\r
\r
unsigned short int count_avoid_regions;\r
-} tag_f_jour_opts_EUR_10;\r
+};\r
\r
-typedef struct f_jour_opts_USA_8\r
+// 52 bytes\r
+struct f_jour_opts_USA_8\r
{\r
int iunkn38;\r
int iunkn39;\r
int iunkn49;\r
// @1a0\r
unsigned short int count_avoid_regions;\r
-} tag_f_jour_opts_USA_8;\r
+};\r
\r
-typedef struct f_jour_opts_USA_10\r
+// 32 bytes\r
+struct f_jour_opts_USA_10\r
{\r
int iunkn38;\r
int iunkn39;\r
int iunkn43;\r
int iunkn44;\r
unsigned short int count_avoid_regions;\r
-} tag_f_jour_opts_USA_10;\r
+};\r
\r
\r
-typedef struct f_jour_avoid\r
+struct f_jour_avoid\r
{\r
float x;\r
float y;\r
int iunkn5;\r
// avoid num? annot?\r
int annot_num;\r
-} tag_f_jour_avoid;\r
+};\r
\r
\r
-typedef struct f_jour_trailer\r
+struct f_jour_trailer\r
{\r
int iunkn0; // =0x65\r
int iunkn1;\r
-} f_tag_jour_trailer;\r
+};\r
\r
-typedef struct jour_rtept\r
+struct jour_rtept\r
{\r
int pthead_os;\r
// mem owned by this struct, as buf does not have terminating null\r
// pointer to pushpin owned by pushpinlist\r
struct pushpin* pushpin;\r
char garmin_ident[7];\r
-} tag_jour_trept;\r
+};\r
\r
struct jour_rtept_rec * jour_rtept_rec_new();\r
void jour_rtept_rec_delete(struct jour_rtept_rec * jourpt_rec);\r
\r
-typedef struct journey\r
+struct journey\r
{\r
int buf_len;\r
char* buf;\r
// an array of ofsets to f_jour_avoid\r
int * avoid_os_list;\r
int trailer_os;\r
-} tag_journey;\r
+};\r
\r
float scaled2deg(int scaled_deg);\r
\r
/*\r
nannol.c\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
#include <stdlib.h>\r
#include <memory.h>\r
#include <math.h>\r
+#include <string.h>\r
\r
#include "gpx.h"\r
#include "st2gpx.h"\r
#include "annotations.h"\r
\r
-//static int readheight = 0;\r
+#ifdef EXPLORE\r
+#include "explore.h"\r
+#endif\r
+\r
+int nullstrcmp(char* str1, char* str2)\r
+{\r
+ if ( (str1==NULL) && (str2==NULL) )\r
+ return 0;\r
+ else if( (str1!=NULL) && (str2!=NULL) )\r
+ return strcmp(str1, str2);\r
+ else if(str1==NULL)\r
+ return -1;\r
+ else\r
+ return 1;\r
+}\r
\r
struct annot_rec * gpx2annot_line_rec(struct gpxpt** ptlist, int num_pts, int annot, int version)\r
{\r
break;\r
}\r
\r
+ // If the last point is 'the same' as the first point,\r
+ // then set this as a closed-line.\r
+ // 'the same' means same name and epsilon-close\r
+ if( (nullstrcmp(ptlist[0]->name, ptlist[num_pts-1]->name) == 0)\r
+ && (fabs(ptlist[0]->lat - ptlist[num_pts-1]->lat) < 0.000001)\r
+ && (fabs(ptlist[0]->lon - ptlist[num_pts-1]->lon) < 0.000001) )\r
+ {\r
+ // set the closed-line flag\r
+ *(unsigned char*)(rec->buf+line_offset-9) = 1;\r
+\r
+ // So that the last point is only implicit\r
+ num_pts--;\r
+\r
+ printf("Last point in a track or route is same as the first point, so removing last point and setting this as a closed line.\n");\r
+ }\r
+\r
// set the annotation (record) number\r
memcpy(rec->buf+4, &annot, 4);\r
// set the number of points in the line\r
/*\r
ppinutil.c\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
#include "gpx.h"\r
#include "st2gpx.h"\r
#include "pushpins.h"\r
-\r
#include "ppinutil.h"\r
\r
+#ifdef EXPLORE\r
+#include "explore.h"\r
+#endif\r
+\r
struct pushpin_safelist * pushpin_safelist_new()\r
{\r
int i;\r
i++;\r
}\r
\r
- printf("Finished reading pushpins\n");\r
+ if (opts.verbose_flag>2)\r
+ printf("Finished reading pushpins\n");\r
fflush(stdout);\r
\r
return ppplist;\r
}\r
\r
-char std_udm1[6] = {18, 0, 0, 0, 0, 0};\r
-char std_udm2[1] = {1};\r
-\r
-void explore_udm_data(struct pushpin_safelist * ppl)\r
-{\r
- int i;\r
- struct f_udm0_header * udm0_head=NULL;\r
- struct f_udm0_header1 * udm0_head1=NULL;\r
- struct f_udm0_ppin * udm0_ppin=NULL;\r
- int expected_udm2_len=0;\r
-\r
- printf("Exploring UDM_Data from UserData\n");\r
-\r
- // check UDM_Data[1]\r
- if(ppl->UDM_Data_length[1] != 6)\r
- printf("Unexpcted UDM_Data[1] length = %d, expected length 6\n", \r
- ppl->UDM_Data_length[1]);\r
- else\r
- for(i=0; i<6; i++)\r
- if(ppl->UDM_Data[1][i] != std_udm1[i])\r
- printf("UDM_Data[1][%d]=%#x, normally expect value %#x\n", \r
- i,\r
- (unsigned char)(ppl->UDM_Data[1][i]), \r
- (unsigned char)(std_udm1[i]));\r
- \r
- // check UDM_Data[2]\r
- if(ppl->UDM_Data_length[2] != 1)\r
- printf("Unexpcted UDM_Data[2] length = %d, expected length 1\n", \r
- ppl->UDM_Data_length[2]);\r
- else\r
- if(ppl->UDM_Data[2][0] != std_udm2[0])\r
- printf("UDM_Data[2][0]=%#x, normally expect value %#x\n", \r
- (unsigned char)ppl->UDM_Data[2][0], \r
- (unsigned char)(std_udm2[0]));\r
-\r
- // check UDM_Data[0]\r
- \r
- if (ppl->UDM_Data_length[0] < 14)\r
- {\r
- printf("UDM_Data[0] is too small to have a valid header\n");\r
- return;\r
- }\r
-\r
- udm0_head = (struct f_udm0_header *)(ppl->UDM_Data[0]);\r
- printf("There are %d highlighted pushpins\n", udm0_head->c_highlight_recs);\r
- // list the highlighted udids? Nah.\r
-\r
- if(udm0_head->sunkn != 0x8001)\r
- {\r
- printf("Unexpected f_udm0_header:\n");\r
- printbuf(ppl->UDM_Data[0], sizeof(struct f_udm0_header));\r
- }\r
-\r
- udm0_head1 = (struct f_udm0_header1*)\r
- (ppl->UDM_Data[0] + sizeof(struct f_udm0_header) \r
- + 4*(udm0_head->c_highlight_recs));\r
- \r
- if( udm0_head1->iunkn != 0)\r
- printf("Unexpected f_udm0_header1->iunkn=%#x:\n",udm0_head1->iunkn);\r
-\r
- expected_udm2_len = (14 + 4*(udm0_head->c_highlight_recs) \r
- + 6*(udm0_head1->c_format_records));\r
- if(ppl->UDM_Data_length[0] != expected_udm2_len)\r
- printf("Unexpcted UDM_Data[0] length = %d, expected length %d for %d indicated format_records\n", \r
- ppl->UDM_Data_length[0], expected_udm2_len, udm0_head1->c_format_records);\r
- else\r
- {\r
- udm0_ppin = (struct f_udm0_ppin *)(ppl->UDM_Data[0] + 14 + 4*(udm0_head->c_highlight_recs) );\r
- // size has already been verified as (14 + 6 * udm0_head->c_format_records)\r
- for(i=0; i<(udm0_head1->c_format_records); i++)\r
- printf("udm0 ppin_rec[%d] has udid=%d, format=%#x, zorder=%d\n",\r
- i, \r
- udm0_ppin[i].ppin_udid, \r
- udm0_ppin[i].format, \r
- udm0_ppin[i].zorder);\r
- }\r
\r
-}
\ No newline at end of file
/*\r
ppinutil.h\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
extern "C" {\r
#endif\r
\r
-// The structures in UserData/UDM_Data for UDMId=0\r
-typedef struct f_udm0_header\r
-{\r
- unsigned short int sunkn; // normally 0x8001\r
- int c_highlight_recs; \r
-} tag_f_udm0_header;\r
-// then c_highlight_recs ints with udid of highlighted ppin\r
-typedef struct f_udm0_header1\r
-{\r
- int iunkn; // normally 0, probably indicates some array length to mess everything up\r
- int c_format_records;\r
-} tag_f_udm0_header1;\r
-// then c_format_records of these:\r
-typedef struct f_udm0_ppin\r
-{\r
- int ppin_udid;\r
- // 1 = show name + info\r
- // (no record if name not shown?)\r
- // 3 = show name\r
- // 4 = upper left\r
- // 8 = upper right\r
- // 12 = lower left\r
- // 16 = lower right\r
- unsigned char format; \r
- unsigned char zorder;\r
-} tag_f_udm0_ppin;\r
-\r
-typedef struct pushpin_safelist\r
+struct pushpin_safelist\r
{\r
struct pushpin ** pushpin_list;\r
int num_pushpins;\r
char * UDM_Data[3];\r
long UDM_Data_length[3];\r
-} tag_pushpin_safelist;\r
+};\r
\r
-typedef struct grid_point {\r
+struct grid_point {\r
long grid;\r
long precision;\r
-} tag_ms_point;\r
+};\r
\r
-typedef struct point {\r
+struct point {\r
double lon;\r
double lat;\r
-} tag_point;\r
+};\r
\r
// max size to be read from ppin memo fields\r
#define MAX_PPIN_MEMO 1000\r
\r
-typedef struct pushpin\r
+struct pushpin\r
{\r
long UdId;\r
int SetId;\r
char garmin_ident[7];\r
char* url;\r
char* urlname;\r
-} tag_pushpin;\r
+} ;\r
\r
\r
// not used yet\r
\r
-typedef struct pushpinset\r
+struct pushpinset\r
{\r
int SetId;\r
char* SetName; // max 128\r
char* DataSrcDescr; // memo\r
char[30] CurrencyData;\r
*/\r
-} tag_pushpinset;\r
+};\r
\r
struct pushpin * pushpin_new();\r
void pushpin_delete(struct pushpin * pp);\r
/*\r
properties.c\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
#include "st2gpx.h"\r
#include "properties.h"\r
\r
+#ifdef EXPLORE\r
+#include "explore.h"\r
+#endif\r
+\r
#define OLE_PROP_STREAM ".Olhud5yvVwudb10uAaq5ezn4Ac"\r
\r
// some types from MS, as published at\r
*(unsigned char*)(fmtid+13),\r
*(unsigned char*)(fmtid+14),\r
*(unsigned char*)(fmtid+15) );\r
- str[39]=0;\r
+ str[38]=0;\r
return str;\r
}\r
\r
dict->ent_propid=(DWORD*)xmalloc(ents*sizeof(DWORD));\r
dict->ent_sz=(char**)xmalloc(ents*sizeof(char*));\r
\r
- printf("reading %d entries from dictionary\n", ents);\r
+ if (opts.verbose_flag > 4)\r
+ printf("reading %d entries from dictionary\n", ents);\r
\r
while(ent_read<ents)\r
{\r
if ((prop_file = fopen(prop_file_name, "rb")) == NULL)\r
{\r
fprintf(stderr, "Cannot open property file %s\n", prop_file_name);\r
- return NULL;\r
+ debug_pause();\r
+ exit(3);\r
+ //return NULL;\r
}\r
\r
status=readbytes(prop_file, (char*)prop_header, sizeof(PROPERTYSETHEADER));\r
/*\r
properties.h\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
\r
typedef unsigned long DWORD;\r
\r
-typedef struct dictionary \r
+struct dictionary \r
{\r
DWORD cEntries; // Count of entries in the list.\r
// array of propids\r
// This next is an array of pointers into properties value,\r
// with the string length preceeding (ie X->ent_cb == X->ent_sz -4)\r
char ** ent_sz; // Zero-terminated string. Code page as indicated. \r
-} tag_dictionary;\r
+};\r
\r
-typedef struct ole_property\r
+struct ole_property\r
{\r
DWORD propid;\r
DWORD dwType; // type tag\r
int buflen;\r
char* buf;\r
-} tag_ole_property;\r
+};\r
\r
-typedef struct ole_property_set\r
+struct ole_property_set\r
{\r
// FMTID fmtid ; // semantic name of a section\r
char fmtid[16]; // semantic name of a section\r
unsigned int cProps;\r
struct dictionary * dict;\r
struct ole_property * pPropList;\r
-} tag_ole_property_set;\r
+};\r
\r
struct ole_property_set * read_ole_properties(char* source_file_name, char* properties_file_name);\r
void ole_property_set_delete(struct ole_property_set * props);\r
/*\r
pushpins.cpp\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
// for vt type values see http://www.canaimasoft.com/f90VB/OnlineManuals/UserManual/TH_99.htm\r
\r
//#import "c:\program files\common files\system\ado\msado15.dll" rename ( "EOF", "adoEOF" )\r
-//#import <msado15.dll> rename ( "EOF", "adoEOF" )\r
-#include "msado15.tlh"\r
-#include "msado15.tli"\r
+#import <msado15.dll> rename ( "EOF", "adoEOF" )\r
+//#include "msado15.tlh"\r
+//#include "msado15.tli"\r
\r
#include <windows.h>\r
#include <initguid.h> // Include only once in your application\r
#include "ppinutil.h"\r
#include "contents.h"\r
\r
-\r
struct InitOle {\r
InitOle() { ::CoInitialize(NULL); }\r
~InitOle() { ::CoUninitialize(); }\r
int val_type=0;\r
char * ppin_sql = NULL;\r
char * UDM_sql = NULL;\r
- char RenderData_buf[4]="";\r
+ char RenderData_buf[8]="";\r
int RenderData_len=0;\r
+ short int NoteTypeId;\r
\r
ppplist->pushpin_list = (struct pushpin **)xmalloc(ppin_list_alloc_size*sizeof(struct pushpin *));\r
\r
if (opts.st_version_num<9)\r
- ppin_sql = "SELECT UD_Secondary.UdId, UD_Secondary.UdName, UD_Secondary.NoteShort, UD_Secondary.NoteLong, UD_Main.Grid, UD_Main.Precision, UD_Main.RenderData, UD_Main.MatchId, UD_Main.MOBBId FROM UD_Main INNER JOIN UD_Secondary ON UD_Main.UdId = UD_Secondary.UdId";\r
+ ppin_sql = "SELECT UD_Secondary.UdId, UD_Secondary.UdName, UD_Secondary.NoteTypeId, UD_Secondary.NoteShort, UD_Secondary.NoteLong, UD_Main.Grid, UD_Main.Precision, UD_Main.RenderData, UD_Main.MatchId, UD_Main.MOBBId FROM UD_Main INNER JOIN UD_Secondary ON UD_Main.UdId = UD_Secondary.UdId;";\r
else\r
- ppin_sql = "SELECT UdId, UdName, NoteShort, NoteLong, Grid, Precision, RenderData, MatchId, MOBBId FROM UD_Main";\r
+ ppin_sql = "SELECT UdId, UdName, NoteTypeId, NoteShort, NoteLong, Grid, Precision, RenderData, MatchId, MOBBId FROM UD_Main;";\r
\r
try \r
{\r
hr = rs->Open(ppin_sql, \r
cnstr, \r
ADODB::adOpenForwardOnly, \r
- ADODB::adLockReadOnly, \r
- -1 );\r
+ ADODB::adLockReadOnly, \r
+ ADODB::adCmdText );\r
\r
while ((rs->adoEOF == FALSE))\r
{\r
variant2val(rs->Fields->GetItem("UdName")->Value, VT_BSTR,&(ppin->UdName), 0);\r
variant2val(rs->Fields->GetItem("Grid")->Value, VT_I4, &(ppin->Grid), 0);\r
variant2val(rs->Fields->GetItem("Precision")->Value,VT_I4, &(ppin->Precision), 0);\r
- variant2val(rs->Fields->GetItem("NoteShort")->Value,VT_BSTR,&(ppin->NoteShort), 0);\r
+ variant2val(rs->Fields->GetItem("NoteTypeId")->Value,VT_I2, &NoteTypeId, 0);\r
+\r
+ if(NoteTypeId==1)\r
+ variant2val(rs->Fields->GetItem("NoteShort")->Value,VT_BSTR,&(ppin->NoteShort), 0);\r
+ else if(NoteTypeId==2)\r
+ variant2val(rs->Fields->GetItem("NoteShort")->Value,VT_BSTR,&(ppin->NoteShort), 0);\r
+ else\r
+ printf("Unexpected NoteTypeId=%d for ppin udid=%d\n", NoteTypeId, ppin->UdId);\r
\r
RenderData_len = rs->Fields->GetItem("RenderData")->ActualSize;\r
val_type = rs->Fields->GetItem("RenderData")->Value.vt;\r
cnstr, \r
ADODB::adOpenForwardOnly, \r
ADODB::adLockReadOnly, \r
- -1 );\r
+ ADODB::adCmdText);\r
\r
while ((rs->adoEOF == FALSE))\r
{\r
ppplist->UDM_Data[UdmDataId]=(char*)xmalloc(ppplist->UDM_Data_length[UdmDataId]);\r
variant2val(rs->Fields->GetItem("UdmData")->Value, VT_ARRAY | VT_UI1, ppplist->UDM_Data[UdmDataId], ppplist->UDM_Data_length[UdmDataId] );\r
\r
- printf("In UDM_Data table, for UdId=%d got %d bytes of data\n",\r
- UdmDataId, ppplist->UDM_Data_length[UdmDataId]);\r
+ if(opts.verbose_flag > 3)\r
+ printf("In UDM_Data table, for UdId=%d got %d bytes of data\n",\r
+ UdmDataId, ppplist->UDM_Data_length[UdmDataId]);\r
\r
if (opts.explore_flag)\r
{\r
catch( _com_error &e)\r
{\r
_bstr_t bstrSource(e.Source());\r
- _bstr_t bs = _bstr_t("*** Exception: ") + _bstr_t(e.Error()) + _bstr_t(" Msg: ") \r
+ _bstr_t bs = _bstr_t("*** Exception in read_pushpins(): ") + _bstr_t(e.Error()) + _bstr_t(" Msg: ") \r
+ _bstr_t(e.ErrorMessage()) + _bstr_t(" Description: ") \r
+ _bstr_t(e.Description());\r
\r
wprintf(bs);\r
+ printf("\n");\r
_flushall();\r
\r
if (opts.verbose_flag>4)\r
cnstr, \r
ADODB::adOpenKeyset, \r
ADODB::adLockOptimistic, \r
- -1 );\r
+ ADODB::adCmdText);\r
\r
variant2val(rs->Fields->GetItem("DbVersion")->Value, VT_I2, &DbVersion, 0);\r
variant2val(rs->Fields->GetItem("LastSetId")->Value, VT_I4, &LastSetId, 0);\r
cnstr, \r
ADODB::adOpenKeyset, \r
ADODB::adLockOptimistic, \r
- -1 );\r
+ ADODB::adCmdText);\r
hr = rs2.CreateInstance( __uuidof( ADODB::Recordset ) );\r
hr = rs2->Open(sql2, \r
cnstr, \r
ADODB::adOpenKeyset, \r
ADODB::adLockOptimistic, \r
- -1 );\r
+ ADODB::adCmdText);\r
}\r
else\r
{\r
cnstr, \r
ADODB::adOpenKeyset, \r
ADODB::adLockOptimistic, \r
- -1 );\r
+ ADODB::adCmdText);\r
}\r
\r
\r
short int sizero=0;\r
short int sione=1;\r
short int sitwo=2;\r
+ short int notetype;\r
\r
// do for each wpt\r
for(w=0; w<all_gpx->wpt_list_count; w++)\r
\r
rs2->Fields->GetItem("UdId" )->Value = val2variant(VT_I4, &thisUserDataId);\r
rs2->Fields->GetItem("UdName" )->Value = val2variant(VT_BSTR,(gpt->name));\r
- rs2->Fields->GetItem("NoteTypeId")->Value = val2variant(VT_I2, &sione);\r
- rs2->Fields->GetItem("NoteShort")->Value = val2variant(VT_BSTR,(gpt->desc));\r
+ \r
+ if(gpt->desc == NULL)\r
+ {\r
+ notetype=1;\r
+ }\r
+ else if(strlen(gpt->desc) < 255)\r
+ {\r
+ notetype=1;\r
+ rs2->Fields->GetItem("NoteShort")->Value = val2variant(VT_BSTR,(gpt->desc));\r
+ }\r
+ else\r
+ {\r
+ notetype=2;\r
+ rs2->Fields->GetItem("NoteLong")->Value = val2variant(VT_BSTR,(gpt->desc));\r
+ }\r
+ rs2->Fields->GetItem("NoteTypeId")->Value = val2variant(VT_I2, ¬etype);\r
rs2->Fields->GetItem("GeocodeHierarchy")->Value = val2variant(VT_I2, &sizero);\r
rs2->Fields->GetItem("GeocodeContext" )->Value = val2variant(VT_I4, &lzero);\r
// sometime I should support this\r
\r
char* SetName = all_gpx->data_source_name;\r
short int RenderMethod = 2;\r
- short int GeocodeMethod = 5;\r
- short int CreateMethod = 2;\r
+ short int GeocodeMethod = 3; //5;\r
+ short int CreateMethod = 1; // using 2 causes mp to crash\r
short int GeometryType = 1;\r
long UdCount=all_gpx->wpt_list_count;\r
long MatchedCount=all_gpx->wpt_list_count;\r
cnstr, \r
ADODB::adOpenKeyset, \r
ADODB::adLockOptimistic, \r
- -1 );\r
+ ADODB::adCmdText);\r
\r
rs->AddNew();\r
\r
catch( _com_error &e)\r
{\r
_bstr_t bstrSource(e.Source());\r
- _bstr_t bs = _bstr_t("*** Exception: ") + _bstr_t(e.Error()) + _bstr_t(" Msg: ") \r
+ _bstr_t bs = _bstr_t("*** Exception in write_pushpins_from_gpx(): ") + _bstr_t(e.Error()) + _bstr_t(" Msg: ") \r
+ _bstr_t(e.ErrorMessage()) + _bstr_t(" Description: ") \r
+ _bstr_t(e.Description());\r
\r
wprintf(bs);\r
+ printf("\n");\r
_flushall();\r
\r
// if (opts.verbose_flag>4)\r
/*\r
pushpins.h\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
/*\r
readgpx.c\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
#include "gpx.h"\r
#include "st2gpx.h"\r
\r
-\r
typedef void (*gpx_elm_start_handler)(void *, const char *, const char **);\r
typedef void (*gpx_elm_end_handler)(void *, const char *);\r
\r
//sym_num=132; // traffic-light\r
else if(strcmp(type_str, "Geocache|Unknown Cache")==0)\r
sym_num=254; // question-mark\r
- else if(strcmp(type_str, "Geocache|Micro Cache")==0)\r
- sym_num=65;\r
+ else if(strcmp(type_str, "Geocache|Micro-Cache")==0)\r
+ sym_num=65; // rotor/X\r
+ else if(strcmp(type_str, "Geocache|Event Cache")==0)\r
+ sym_num=138; // knife & fork\r
\r
switch (current_main_element)\r
{\r
/*\r
readmpst.c\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
/*\r
st2gpx.c\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
*/\r
\r
#include <stdio.h>\r
+#include <io.h>\r
#include <stdlib.h>\r
#include <memory.h>\r
#include <math.h>\r
#include <string.h>\r
-\r
+#include <direct.h>\r
#include <malloc.h>\r
#include <crtdbg.h>\r
\r
return nw;\r
}\r
\r
+char* buf2str(char* buf, int strlen)\r
+// make a null-terminated string from a buf\r
+{\r
+ char*str=NULL;\r
+ if (strlen==0)\r
+ return NULL;\r
+ str=(char*)xmalloc(strlen+1);\r
+ memcpy(str, buf, strlen);\r
+ str[strlen]=0;\r
+ return str;\r
+}\r
+\r
+char* buf2wstr(char* buf, int strlen)\r
+// make a null-terminated wide string from a buf\r
+// strlen is the number of characters, not len\r
+{\r
+ char*str=NULL;\r
+ if (strlen==0)\r
+ return NULL;\r
+ str=(char*)xmalloc(2*strlen+1);\r
+ memcpy(str, buf, 2*strlen);\r
+ str[2*strlen]=0;\r
+ str[2*strlen + 1]=0;\r
+ return str;\r
+}\r
+\r
int readbytes(FILE* file, char* buf, int bytes2read)\r
{\r
int i;\r
\r
void show_usage()\r
{\r
- printf("st2gpx - Export data from MS Streets & Trips and Autoroute to GPX format\n\n");\r
+ printf("st2gpx - Export data from MS Streets & Trips, Autoroute and Mappoint to GPX format\n\n");\r
// FIXME update this line\r
printf("Usage: st2gpx [-hr] [-v verbose-level] [-g gpx-in-file] [-G gpx-out-file]");\r
printf(" [-m mpst-in-file] [-M pcx5-out-file] [-F st-mod-file] stfile\n\n");\r
void xsystem(char* syscmd)\r
{\r
int status;\r
- printf("%s \n", syscmd);\r
+ int original_stderr;\r
+ char* tempname=NULL;\r
+ FILE* tempfile;\r
+\r
+ if (opts.verbose_flag > 2)\r
+ printf("%s \n", syscmd);\r
+ else\r
+ {\r
+ // Throw away stderr from the system call.\r
+ // Actually, I just write it to a temp file.\r
+ original_stderr = _dup(2); // duplicate stderr\r
+ if( original_stderr == -1 )\r
+ {\r
+ perror( "_dup( 2 ) failure" );\r
+ exit( 1 );\r
+ }\r
+\r
+ tempname = tmpnam(tempname);\r
+ if( (tempname==NULL) || (( tempfile = fopen(tempname, "w") ) == NULL ))\r
+ {\r
+ puts( "Can't open tempfile for stderr\n" );\r
+ exit( 1 );\r
+ }\r
+ // stderr now refers to tempfile \r
+ if( -1 == _dup2( _fileno( tempfile ), 2 ) )\r
+ {\r
+ perror( "Can't _dup2 stderr" );\r
+ exit( 1 );\r
+ }\r
+ }\r
+\r
_flushall();\r
status = system(syscmd);\r
+\r
+ if (opts.verbose_flag < 3)\r
+ {\r
+ // restore stderr\r
+ fflush( tempfile );\r
+ fflush( stderr );\r
+ fclose( tempfile );\r
+ _dup2( original_stderr, 2 );\r
+ remove(tempname);\r
+ }\r
+\r
if (status)\r
- fprintf(stderr, "system call returned an error\n");\r
+ fprintf(stderr, "system call returned error %d\n", status);\r
}\r
\r
main(int argc, char** argv)\r
char cmdext[_MAX_EXT];\r
char * cmdpath=NULL;\r
\r
+ char file1[_MAX_PATH];\r
+ char file2[_MAX_PATH];\r
\r
struct pushpin_safelist* ppplist=NULL;\r
struct journey* jour=NULL;\r
\r
#ifdef MEMCHK\r
// Call _CrtCheckMemory at every allocation and deallocation request.\r
- SET_CRT_DEBUG_FIELD(_CRTDBG_CHECK_ALWAYS_DF);\r
+// SET_CRT_DEBUG_FIELD(_CRTDBG_CHECK_ALWAYS_DF);\r
// Keep freed memory blocks in the heaps linked list, assign them the _FREE_BLOCK type,\r
// and fill them with the byte value 0xDD.\r
SET_CRT_DEBUG_FIELD(_CRTDBG_DELAY_FREE_MEM_DF);\r
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );\r
#endif\r
\r
- // _CrtSetBreakAlloc(136);\r
-\r
+ // Set this to find where leaking mem was allocated\r
+ //_CrtSetBreakAlloc(209);\r
\r
while (1)\r
{\r
opts.source_file_name = (char*)xmalloc(strlen(argv[optind])+1);\r
strcpy(opts.source_file_name, argv[optind]);\r
if (opts.verbose_flag > 1)\r
- printf("Analysing autoroute file %s\n\n", opts.source_file_name);\r
+ printf("Analysing MS Map file %s\n\n", opts.source_file_name);\r
if (ppin_in_file_name==NULL)\r
ppin_in_file_name = strappend(opts.source_file_name, ".Contents\\UserData.mdb");\r
if (jour_in_file_name==NULL)\r
{\r
printf("Unrecognised option %s\n", argv[optind+1]);\r
show_usage();\r
-\r
}\r
else\r
{\r
if (opts.verbose_flag > 1)\r
- printf("Not analysing any core S&T or autoroute file\n");\r
+ printf("Not analysing any core MS Map file\n");\r
}\r
\r
if (opts.source_file_name)\r
\r
// Find the path for istorage from the path in argv[0]\r
\r
- // this is not ANSI\r
_splitpath(argv[0], cmddrv, cmddir, cmdfilename, cmdext);\r
- //sprintf(cmdpath, "%s%s", cmddrv, cmddir);\r
cmdpath = strappend(cmddrv, cmddir);\r
\r
_fullpath(source_full_path, opts.source_file_name, _MAX_PATH);\r
sprintf(syscmd, "%sistorage\\istorage.exe \"%s\"", cmdpath, source_full_path);\r
xsystem(syscmd);\r
\r
- printf("*****************************************************************\n");\r
- printf("Finished istorage command\n");\r
-\r
- sprintf(syscmd, "rename \"%s.Contents\\UserData.\" UserData.mdb", opts.source_file_name);\r
- xsystem(syscmd);\r
+ sprintf(file1, "%s.Contents\\UserData.", opts.source_file_name);\r
+ sprintf(file2, "%s.Contents\\UserData.mdb", opts.source_file_name);\r
+ rename(file1, file2);\r
}\r
\r
// ***************************\r
if (all_gpx==NULL)\r
printf("Didn't read any usable data from %s ???\n",gpx_in_file_name);\r
printf("Read %d waypoints, %d routes and %d tracks from file %s\n", all_gpx->wpt_list_count, all_gpx->rte_list_count, all_gpx->trk_list_count, gpx_in_file_name);\r
- printf("Importing this data as %d lines\n", all_gpx->rte_list_count + all_gpx->trk_list_count);\r
+ printf("Importing this data as %d pushpins and %d lines\n", all_gpx->wpt_list_count, all_gpx->rte_list_count + all_gpx->trk_list_count);\r
}\r
\r
// Read Mapsource text-export file.\r
printf("Read %d waypoints, %d routes and %d tracks from file %s\n",\r
all_gpx->wpt_list_count, all_gpx->rte_list_count,\r
all_gpx->trk_list_count, mpst_in_file_name);\r
- printf("Importing this data as %d lines\n",\r
+ printf("Importing this data as %d pushpins and %d lines\n",\r
+ all_gpx->wpt_list_count,\r
all_gpx->rte_list_count + all_gpx->trk_list_count);\r
}\r
\r
- // ole properties from S&T source file\r
+ // ole properties from S&T/Autoreoute/Mappoint source file\r
if (opts.source_file_name)\r
{\r
strips_properties=read_ole_properties(opts.source_file_name, NULL);\r
if ((prop!=NULL) && (prop->buf != NULL) )\r
{\r
opts.st_version_num = *(int*)(prop->buf);\r
- printf("Autoroute/S&T version in %s is %d\n", opts.source_file_name, opts.st_version_num);\r
+ printf("MS Map version in %s is %d\n", opts.source_file_name, opts.st_version_num);\r
}\r
prop = get_propterty(strips_properties, 0x10000);\r
if ((prop!=NULL) && (prop->buf != NULL) )\r
if (annots==NULL)\r
printf("After merging data, dont have any annotations???\n");\r
printf("After merging data, there are %d annotations\n", annots->num_annotations);\r
- //print_annotations(annots);\r
write_annotations(annots, annot_in_file_name);\r
- //print_annotations(annots);\r
\r
- // ********************\r
- // This is experimantal\r
- // ********************\r
- temp_str = strappend(opts.source_file_name, ".Contents\\Contents");\r
- write_pushpins_from_gpx(ppin_in_file_name, all_gpx, conts, temp_str);\r
- free(temp_str);\r
- temp_str=NULL;\r
+ sprintf(file1, "%s.Contents\\Contents", opts.source_file_name);\r
+ write_pushpins_from_gpx(ppin_in_file_name, all_gpx, conts, file1);\r
}\r
\r
- // create the s&t/autoroute file from the modified parts\r
+ // create the s&t/autoroute/mappoint file from the modified parts\r
if ((opts.source_file_name!=NULL) && (all_gpx!=NULL) && (import_file_name!=NULL))\r
{\r
// Actually, we should allow NULL import_file_name and invent a sensible name\r
\r
- sprintf(syscmd, "rename %s.Contents\\UserData.mdb UserData.", opts.source_file_name);\r
- xsystem(syscmd);\r
+ sprintf(file1, "%s.Contents\\UserData.mdb", opts.source_file_name);\r
+ sprintf(file2, "%s.Contents\\UserData.", opts.source_file_name);\r
+ rename(file1, file2);\r
\r
contents_dir_name=(char*)xmalloc(strlen(opts.source_file_name)+20);\r
sprintf(contents_dir_name, "%s.Contents", opts.source_file_name);\r
sprintf(syscmd, "%sistorage\\istorage-make.exe \"%s\"", cmdpath, contents_full_path);\r
xsystem(syscmd);\r
\r
- printf("*****************************************************************\n");\r
- printf("Finished istorage-make command\n");\r
-\r
- sprintf(syscmd, "del \"%s\"", import_file_name);\r
- xsystem(syscmd);\r
+ remove(import_file_name);\r
\r
_splitpath(opts.source_file_name, cmddrv, cmddir, cmdfilename, cmdext);\r
- sprintf(syscmd, "move \"%s.Contents.ole\" \"%s\"", opts.source_file_name, import_file_name);\r
- xsystem(syscmd);\r
-\r
+ sprintf(file1, "%s.Contents.ole", opts.source_file_name);\r
+ rename(file1, import_file_name);\r
}\r
\r
// Clean up the compound file directory\r
if (opts.source_file_name)\r
{\r
{\r
- sprintf(syscmd, "echo y|del \"%s.Contents\"", opts.source_file_name);\r
+ sprintf(syscmd, "echo y|del \"%s.Contents\" > null", opts.source_file_name);\r
xsystem(syscmd);\r
\r
- sprintf(syscmd, "rmdir \"%s.Contents\"", opts.source_file_name);\r
- xsystem(syscmd);\r
+ sprintf(file1, "%s.Contents", opts.source_file_name);\r
+ _rmdir(file1);\r
}\r
}\r
\r
if (opts.verbose_flag>5)\r
printf("Done freeing all\n");\r
\r
- //debug_show_sizes();\r
- //debug_pause();\r
- //printf("exiting main\n");\r
-\r
_flushall();\r
\r
-#ifdef _DEBUG\r
+//#ifdef _DEBUG\r
// _CrtDumpMemoryLeaks();\r
-#endif\r
+//#endif\r
+ printf("All done.\n");\r
debug_pause();\r
}\r
+++ /dev/null
-# Microsoft Developer Studio Project File - Name="st2gpx" - Package Owner=<4>\r
-# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
-# ** DO NOT EDIT **\r
-\r
-# TARGTYPE "Win32 (x86) Console Application" 0x0103\r
-\r
-CFG=st2gpx - Win32 Debug\r
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
-!MESSAGE use the Export Makefile command and run\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "st2gpx.mak".\r
-!MESSAGE \r
-!MESSAGE You can specify a configuration when running NMAKE\r
-!MESSAGE by defining the macro CFG on the command line. For example:\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "st2gpx.mak" CFG="st2gpx - Win32 Debug"\r
-!MESSAGE \r
-!MESSAGE Possible choices for configuration are:\r
-!MESSAGE \r
-!MESSAGE "st2gpx - Win32 Release" (based on "Win32 (x86) Console Application")\r
-!MESSAGE "st2gpx - Win32 Debug" (based on "Win32 (x86) Console Application")\r
-!MESSAGE \r
-\r
-# Begin Project\r
-# PROP AllowPerConfigDependencies 0\r
-# PROP Scc_ProjName ""\r
-# PROP Scc_LocalPath ""\r
-CPP=cl.exe\r
-RSC=rc.exe\r
-\r
-!IF "$(CFG)" == "st2gpx - Win32 Release"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 0\r
-# PROP BASE Output_Dir "Release"\r
-# PROP BASE Intermediate_Dir "Release"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 0\r
-# PROP Output_Dir "Release"\r
-# PROP Intermediate_Dir "Release"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
-# ADD CPP /nologo /Zp1 /Za /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
-# ADD BASE RSC /l 0x409 /d "NDEBUG"\r
-# ADD RSC /l 0x409 /d "NDEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\r
-# ADD LINK32 libexpat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\r
-# SUBTRACT LINK32 /debug\r
-\r
-!ELSEIF "$(CFG)" == "st2gpx - Win32 Debug"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 1\r
-# PROP BASE Output_Dir "Debug"\r
-# PROP BASE Intermediate_Dir "Debug"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 1\r
-# PROP Output_Dir "Debug"\r
-# PROP Intermediate_Dir "Debug"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c\r
-# ADD CPP /nologo /Zp1 /Za /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c\r
-# ADD BASE RSC /l 0x409 /d "_DEBUG"\r
-# ADD RSC /l 0x409 /d "_DEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\r
-# ADD LINK32 libexpat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\r
-# SUBTRACT LINK32 /profile /map\r
-\r
-!ENDIF \r
-\r
-# Begin Target\r
-\r
-# Name "st2gpx - Win32 Release"\r
-# Name "st2gpx - Win32 Debug"\r
-# Begin Group "Source Files"\r
-\r
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
-# Begin Source File\r
-\r
-SOURCE=.\annotations.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\contents.c\r
-\r
-!IF "$(CFG)" == "st2gpx - Win32 Release"\r
-\r
-!ELSEIF "$(CFG)" == "st2gpx - Win32 Debug"\r
-\r
-# ADD CPP /Za\r
-\r
-!ENDIF \r
-\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\debug.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\getopt.c\r
-# ADD CPP /Ze\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\journey.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\nannol.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\ppinutil.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\properties.c\r
-# ADD CPP /Ze\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\pushpins.cpp\r
-# ADD CPP /Ze\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\readgpx.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\readmpst.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\st2gpx.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\writegpx.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\writepcx.c\r
-# End Source File\r
-# End Group\r
-# Begin Group "Header Files"\r
-\r
-# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
-# Begin Source File\r
-\r
-SOURCE=.\annotations.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\contents.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\getopt.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\gpx.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\journey.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\ppinutil.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\properties.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\pushpins.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\st2gpx.h\r
-# End Source File\r
-# End Group\r
-# Begin Group "Resource Files"\r
-\r
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
-# End Group\r
-# Begin Source File\r
-\r
-SOURCE=.\bugs.txt\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\build.txt\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\history.txt\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\ToDo.txt\r
-# End Source File\r
-# End Target\r
-# End Project\r
/*
st2gpx.h
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.
+ Extract data from MS Streets & Trips .est, Autoroute .axe
+ and Mapoint .ptm files in GPX format.
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com
extern "C" {
#endif
+//#define EXPLORE
#ifdef _DEBUG
-\r
#define MEMCHK\r
#define DEBUG_STDOUT\r
\r
typedef unsigned short WCHAR;
-typedef struct st2gpx_options
+struct st2gpx_options
{
// 0 - only errors
// 1 also the structured data output, e.g. line point info
// 0 for EUR, i.e. Autoroute
// 1 for USA, i,e, Streets & Trips
unsigned char isUSA;
-} tag_st2gpx_options;
+};
// FIXME is this the correct way to forward define these?
extern struct pushpin_safelist;
extern struct annot_rec ;
extern struct gpx_data;
-extern struct f_jour_pt_head;
-extern struct f_jour_pt_tail;
-extern struct f_jour_opts_EUR_8;
-extern struct f_jour_opts_EUR_10;
-extern struct f_jour_opts_USA_8;
-extern struct f_jour_opts_USA_10;
-extern struct f_jour_opts;
-extern struct f_jour_avoid;
-extern struct f_jour_trailer;
extern struct journey;
-extern struct f_jour_header;
extern struct contents;
#endif // __cplusplus
void * xmalloc(size_t size);
void * xrealloc(void* ptr, size_t size);
char * str2ascii(char* str);\r
-char * strappend(char* str1, char* str2);
+char * strappend(char* str1, char* str2);\r
+char * buf2str(char* buf, int strlen);
+char * buf2wstr(char* buf, int strlen);\r
int readbytes(FILE* file, char* buf, int bytes2read);
//nannol.c
struct annotations * merge_gpx_annot(struct annotations * annots, struct gpx_data* all_gpx);
//debug.c
void debug_pause();
void printbuf(char* buf, int len);
-void explore_annot(struct annot_rec * rec);
-void print_f_jour_header(struct f_jour_header * head);
-void print_f_jour_pt_head(struct f_jour_pt_head * pt_head);
-void print_f_jour_pt_tail(struct f_jour_pt_tail * pt_tail);
-void print_f_jour_opts(struct f_jour_opts * jopts);
-void print_f_jour_opts_EUR_8(struct f_jour_opts_EUR_8 * jopts);
-void print_f_jour_opts_EUR_10(struct f_jour_opts_EUR_10 * jopts);
-void print_f_jour_opts_USA_8(struct f_jour_opts_USA_8 * jopts);
-void print_f_jour_opts_USA_10(struct f_jour_opts_USA_10 * jopts);
-void print_f_jour_avoid(struct f_jour_avoid * avoid);
-void print_f_jour_trailer(struct f_jour_trailer * trailer);
-void print_annot_rec(struct annot_rec * rec);
-void print_annotations(struct annotations * annots);
void debug_show_sizes();
//st2gpx.c
struct gpx_data * read_mpstext(char* mpstxt_file_name);
--- /dev/null
+Microsoft Visual Studio Solution File, Format Version 8.00\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "st2gpx", "st2gpx.vcproj", "{3D8C8F70-1814-4424-99FF-F52C7B74C77A}"\r
+ ProjectSection(ProjectDependencies) = postProject\r
+ EndProjectSection\r
+EndProject\r
+Global\r
+ GlobalSection(SolutionConfiguration) = preSolution\r
+ Debug = Debug\r
+ Release = Release\r
+ EndGlobalSection\r
+ GlobalSection(ProjectConfiguration) = postSolution\r
+ {3D8C8F70-1814-4424-99FF-F52C7B74C77A}.Debug.ActiveCfg = Debug|Win32\r
+ {3D8C8F70-1814-4424-99FF-F52C7B74C77A}.Debug.Build.0 = Debug|Win32\r
+ {3D8C8F70-1814-4424-99FF-F52C7B74C77A}.Release.ActiveCfg = Release|Win32\r
+ {3D8C8F70-1814-4424-99FF-F52C7B74C77A}.Release.Build.0 = Release|Win32\r
+ EndGlobalSection\r
+ GlobalSection(ExtensibilityGlobals) = postSolution\r
+ EndGlobalSection\r
+ GlobalSection(ExtensibilityAddIns) = postSolution\r
+ EndGlobalSection\r
+EndGlobal\r
--- /dev/null
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+ ProjectType="Visual C++"\r
+ Version="7.10"\r
+ Name="st2gpx"\r
+ SccProjectName=""\r
+ SccLocalPath="">\r
+ <Platforms>\r
+ <Platform\r
+ Name="Win32"/>\r
+ </Platforms>\r
+ <Configurations>\r
+ <Configuration\r
+ Name="Debug|Win32"\r
+ OutputDirectory=".\Debug"\r
+ IntermediateDirectory=".\Debug"\r
+ ConfigurationType="1"\r
+ UseOfMFC="0"\r
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"\r
+ CharacterSet="2">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ ImproveFloatingPointConsistency="TRUE"\r
+ AdditionalIncludeDirectories=""I:\Expat-1.95.7\Source\lib";"c:\program files\common files\system\ado""\r
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
+ MinimalRebuild="TRUE"\r
+ BasicRuntimeChecks="3"\r
+ RuntimeLibrary="5"\r
+ StructMemberAlignment="1"\r
+ DisableLanguageExtensions="TRUE"\r
+ UsePrecompiledHeader="2"\r
+ PrecompiledHeaderFile=".\Debug/st2gpx.pch"\r
+ AssemblerListingLocation=".\Debug/"\r
+ ObjectFile=".\Debug/"\r
+ ProgramDataBaseFileName=".\Debug/"\r
+ BrowseInformation="1"\r
+ WarningLevel="3"\r
+ SuppressStartupBanner="FALSE"\r
+ DebugInformationFormat="4"/>\r
+ <Tool\r
+ Name="VCCustomBuildTool"/>\r
+ <Tool\r
+ Name="VCLinkerTool"\r
+ AdditionalDependencies="libexpat.lib odbc32.lib odbccp32.lib"\r
+ OutputFile=".\Debug/st2gpx.exe"\r
+ SuppressStartupBanner="TRUE"\r
+ AdditionalLibraryDirectories="i:\Expat-1.95.7\Libs"\r
+ GenerateDebugInformation="TRUE"\r
+ ProgramDatabaseFile=".\Debug/st2gpx.pdb"\r
+ SubSystem="1"\r
+ TargetMachine="1"/>\r
+ <Tool\r
+ Name="VCMIDLTool"\r
+ TypeLibraryName=".\Debug/st2gpx.tlb"\r
+ HeaderFileName=""/>\r
+ <Tool\r
+ Name="VCPostBuildEventTool"/>\r
+ <Tool\r
+ Name="VCPreBuildEventTool"/>\r
+ <Tool\r
+ Name="VCPreLinkEventTool"/>\r
+ <Tool\r
+ Name="VCResourceCompilerTool"\r
+ PreprocessorDefinitions="_DEBUG"\r
+ Culture="1033"/>\r
+ <Tool\r
+ Name="VCWebServiceProxyGeneratorTool"/>\r
+ <Tool\r
+ Name="VCXMLDataGeneratorTool"/>\r
+ <Tool\r
+ Name="VCWebDeploymentTool"/>\r
+ <Tool\r
+ Name="VCManagedWrapperGeneratorTool"/>\r
+ <Tool\r
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>\r
+ </Configuration>\r
+ <Configuration\r
+ Name="Release|Win32"\r
+ OutputDirectory=".\Release"\r
+ IntermediateDirectory=".\Release"\r
+ ConfigurationType="1"\r
+ UseOfMFC="0"\r
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"\r
+ CharacterSet="2">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="2"\r
+ InlineFunctionExpansion="1"\r
+ ImproveFloatingPointConsistency="TRUE"\r
+ AdditionalIncludeDirectories=""I:\Expat-1.95.7\Source\lib";"c:\program files\common files\system\ado""\r
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
+ StringPooling="TRUE"\r
+ RuntimeLibrary="4"\r
+ StructMemberAlignment="1"\r
+ EnableFunctionLevelLinking="TRUE"\r
+ DisableLanguageExtensions="TRUE"\r
+ UsePrecompiledHeader="2"\r
+ PrecompiledHeaderFile=".\Release/st2gpx.pch"\r
+ AssemblerListingLocation=".\Release/"\r
+ ObjectFile=".\Release/"\r
+ ProgramDataBaseFileName=".\Release/"\r
+ WarningLevel="3"\r
+ SuppressStartupBanner="TRUE"/>\r
+ <Tool\r
+ Name="VCCustomBuildTool"/>\r
+ <Tool\r
+ Name="VCLinkerTool"\r
+ AdditionalDependencies="libexpat.lib odbc32.lib odbccp32.lib"\r
+ OutputFile=".\Release/st2gpx.exe"\r
+ LinkIncremental="1"\r
+ SuppressStartupBanner="TRUE"\r
+ AdditionalLibraryDirectories="i:\Expat-1.95.7\Libs"\r
+ ProgramDatabaseFile=".\Release/st2gpx.pdb"\r
+ SubSystem="1"\r
+ TargetMachine="1"/>\r
+ <Tool\r
+ Name="VCMIDLTool"\r
+ TypeLibraryName=".\Release/st2gpx.tlb"\r
+ HeaderFileName=""/>\r
+ <Tool\r
+ Name="VCPostBuildEventTool"/>\r
+ <Tool\r
+ Name="VCPreBuildEventTool"/>\r
+ <Tool\r
+ Name="VCPreLinkEventTool"/>\r
+ <Tool\r
+ Name="VCResourceCompilerTool"\r
+ PreprocessorDefinitions="NDEBUG"\r
+ Culture="1033"/>\r
+ <Tool\r
+ Name="VCWebServiceProxyGeneratorTool"/>\r
+ <Tool\r
+ Name="VCXMLDataGeneratorTool"/>\r
+ <Tool\r
+ Name="VCWebDeploymentTool"/>\r
+ <Tool\r
+ Name="VCManagedWrapperGeneratorTool"/>\r
+ <Tool\r
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>\r
+ </Configuration>\r
+ </Configurations>\r
+ <References>\r
+ </References>\r
+ <Files>\r
+ <Filter\r
+ Name="Source Files"\r
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">\r
+ <File\r
+ RelativePath="annotations.c">\r
+ <FileConfiguration\r
+ Name="Debug|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ PreprocessorDefinitions=""\r
+ BasicRuntimeChecks="3"\r
+ BrowseInformation="1"/>\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="2"\r
+ PreprocessorDefinitions=""/>\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="contents.c">\r
+ <FileConfiguration\r
+ Name="Debug|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ PreprocessorDefinitions=""\r
+ BasicRuntimeChecks="3"\r
+ BrowseInformation="1"/>\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="2"\r
+ PreprocessorDefinitions=""/>\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="debug.c">\r
+ <FileConfiguration\r
+ Name="Debug|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ PreprocessorDefinitions=""\r
+ BasicRuntimeChecks="3"\r
+ BrowseInformation="1"/>\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="2"\r
+ PreprocessorDefinitions=""/>\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="getopt.c">\r
+ <FileConfiguration\r
+ Name="Debug|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ PreprocessorDefinitions=""\r
+ BasicRuntimeChecks="3"\r
+ DisableLanguageExtensions="FALSE"\r
+ BrowseInformation="1"/>\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="2"\r
+ PreprocessorDefinitions=""\r
+ DisableLanguageExtensions="FALSE"/>\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="journey.c">\r
+ <FileConfiguration\r
+ Name="Debug|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ PreprocessorDefinitions=""\r
+ BasicRuntimeChecks="3"\r
+ BrowseInformation="1"/>\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="2"\r
+ PreprocessorDefinitions=""/>\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="nannol.c">\r
+ <FileConfiguration\r
+ Name="Debug|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ PreprocessorDefinitions=""\r
+ BasicRuntimeChecks="3"\r
+ BrowseInformation="1"/>\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="2"\r
+ PreprocessorDefinitions=""/>\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="ppinutil.c">\r
+ <FileConfiguration\r
+ Name="Debug|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ PreprocessorDefinitions=""\r
+ BasicRuntimeChecks="3"\r
+ BrowseInformation="1"/>\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="2"\r
+ PreprocessorDefinitions=""/>\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="properties.c">\r
+ <FileConfiguration\r
+ Name="Debug|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ PreprocessorDefinitions=""\r
+ BasicRuntimeChecks="3"\r
+ DisableLanguageExtensions="FALSE"\r
+ BrowseInformation="1"/>\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="2"\r
+ PreprocessorDefinitions=""\r
+ DisableLanguageExtensions="FALSE"/>\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="pushpins.cpp">\r
+ <FileConfiguration\r
+ Name="Debug|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ PreprocessorDefinitions=""\r
+ BasicRuntimeChecks="3"\r
+ DisableLanguageExtensions="FALSE"\r
+ BrowseInformation="1"/>\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="2"\r
+ PreprocessorDefinitions=""\r
+ DisableLanguageExtensions="FALSE"/>\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="readgpx.c">\r
+ <FileConfiguration\r
+ Name="Debug|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ PreprocessorDefinitions=""\r
+ BasicRuntimeChecks="3"\r
+ BrowseInformation="1"/>\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="2"\r
+ PreprocessorDefinitions=""/>\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="readmpst.c">\r
+ <FileConfiguration\r
+ Name="Debug|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ PreprocessorDefinitions=""\r
+ BasicRuntimeChecks="3"\r
+ BrowseInformation="1"/>\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="2"\r
+ PreprocessorDefinitions=""/>\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="st2gpx.c">\r
+ <FileConfiguration\r
+ Name="Debug|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ PreprocessorDefinitions=""\r
+ BasicRuntimeChecks="3"\r
+ BrowseInformation="1"/>\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="2"\r
+ PreprocessorDefinitions=""/>\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="writegpx.c">\r
+ <FileConfiguration\r
+ Name="Debug|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ PreprocessorDefinitions=""\r
+ BasicRuntimeChecks="3"\r
+ BrowseInformation="1"/>\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="2"\r
+ PreprocessorDefinitions=""/>\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="writepcx.c">\r
+ <FileConfiguration\r
+ Name="Debug|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ PreprocessorDefinitions=""\r
+ BasicRuntimeChecks="3"\r
+ BrowseInformation="1"/>\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|Win32">\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="2"\r
+ PreprocessorDefinitions=""/>\r
+ </FileConfiguration>\r
+ </File>\r
+ </Filter>\r
+ <Filter\r
+ Name="Header Files"\r
+ Filter="h;hpp;hxx;hm;inl">\r
+ <File\r
+ RelativePath="annotations.h">\r
+ </File>\r
+ <File\r
+ RelativePath="contents.h">\r
+ </File>\r
+ <File\r
+ RelativePath="getopt.h">\r
+ </File>\r
+ <File\r
+ RelativePath="gpx.h">\r
+ </File>\r
+ <File\r
+ RelativePath="journey.h">\r
+ </File>\r
+ <File\r
+ RelativePath="ppinutil.h">\r
+ </File>\r
+ <File\r
+ RelativePath="properties.h">\r
+ </File>\r
+ <File\r
+ RelativePath="pushpins.h">\r
+ </File>\r
+ <File\r
+ RelativePath="st2gpx.h">\r
+ </File>\r
+ </Filter>\r
+ <Filter\r
+ Name="Resource Files"\r
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">\r
+ </Filter>\r
+ <File\r
+ RelativePath="bugs.txt">\r
+ </File>\r
+ <File\r
+ RelativePath="build.txt">\r
+ </File>\r
+ <File\r
+ RelativePath="history.txt">\r
+ </File>\r
+ <File\r
+ RelativePath="ToDo.txt">\r
+ </File>\r
+ </Files>\r
+ <Globals>\r
+ </Globals>\r
+</VisualStudioProject>\r
/*\r
writegpx.c\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
#define GPX_TRKPT 2\r
char * gpxptypelabel[3] = {"wpt", "rtept", "trkpt"};\r
\r
+// Sequential numbering of track-points\r
+int pt_num;\r
+\r
FILE* gpx_open_write_file_header(char* gpx_out_file_name)\r
{\r
FILE* gpx_out_file=NULL;\r
{\r
int i;\r
struct gpxpt * pt=NULL;\r
-// char* opt_elms;\r
-// int optlen;\r
\r
if ((gpx_out_file==NULL) || (ppplist==NULL))\r
return;\r
\r
pt = gpxpt_new();\r
\r
- printf("writting gpx waypoints for %d pushpins\n", ppplist->num_pushpins);\r
+ printf("writing gpx waypoints for %d pushpins\n", ppplist->num_pushpins);\r
\r
for (i=0; i<ppplist->num_pushpins; i++)\r
{\r
if (ppplist->pushpin_list[i]==NULL)\r
break;\r
\r
-// optlen = strlen(ppplist->pushpin_list[i]->UdName)\r
-// + strlen(ppplist->pushpin_list[i]->NoteShort) + 60;\r
-// opt_elms = (char*)xmalloc(optlen);\r
-\r
-// sprintf(opt_elms, "<name><![CDATA[%s]]></name><desc><![CDATA[%s]]></desc>",\r
-// ppplist->pushpin_list[i]->UdName, ppplist->pushpin_list[i]->NoteShort);\r
-\r
pt->name = _strdup(ppplist->pushpin_list[i]->UdName);\r
pt->desc = _strdup(ppplist->pushpin_list[i]->NoteShort);\r
\r
pt->symbol = ppplist->pushpin_list[i]->RenderData;\r
\r
gpx_write_point(gpx_out_file, pt, GPX_WPT);\r
-// free(opt_elms);\r
free(pt->name);\r
pt->name=NULL;\r
free(pt->desc);\r
gpxpt_delete(pt);\r
}\r
\r
-void gpx_write_annot_rec(FILE* gpx_out_file, struct annot_rec * rec)\r
+void gpx_write_annot_rec(FILE* gpx_out_file, struct annot_rec * rec, int annot_version)\r
{\r
int pt_type;\r
int p;\r
-// char opt_elms[200];\r
- struct gpxpt * pt;\r
+ struct gpxpt * pt=NULL;\r
+ struct gpxpt * first_point = NULL;\r
+ int point_os;\r
+ int data_os;\r
+ int c_shape_points;\r
\r
if ( (gpx_out_file==NULL) || (rec==NULL) )\r
{\r
// *******************\r
\r
\r
- for (p=0; p < rec->line_points; p++)\r
+ for (p=0; p < rec->line_points; p++, pt_num++)\r
{\r
pt=gpx_get_point(rec->buf + rec->line_offset + 12*p);\r
- pt->name=(char*)xmalloc(7);\r
+ // I wanted to keep pt names less that 6 chars, \r
+ // but there can be large polylines e.g with more than 30,000 pts\r
+ if(pt_num>9999999)\r
+ {\r
+ printf("Too many points\n");\r
+ exit(0);\r
+ }\r
+ pt->name=(char*)xmalloc(10);\r
if(pt==NULL)\r
{\r
printf("got null pt #%p in annotation %d, skipping more points in this annotation\n",\r
break;\r
}\r
if(opts.use_gpx_route)\r
- sprintf(pt->name, "rp%04d", p);\r
- //sprintf(opt_elms, "<name>rp%04d</name>", p);\r
+ sprintf(pt->name, "rp%04d", pt_num);\r
else\r
// we need to include a name for trackpoints\r
// for them to be recognised by easygps.\r
- sprintf(pt->name, "tp%04d", p);\r
- //sprintf(opt_elms, "<name>tp%04d</name>", p);\r
+ sprintf(pt->name, "tp%04d", pt_num);\r
gpx_write_point(gpx_out_file, pt, pt_type);\r
+ if(p==0)\r
+ first_point = gpxpt_copy(pt);\r
gpxpt_delete(pt);\r
}\r
-\r
+ \r
+ // If this is a closed poly-line, then add the first point\r
+ // as the implicit last point.\r
+ if(rec->is_closed_line_flag)\r
+ gpx_write_point(gpx_out_file, first_point, pt_type);\r
+ gpxpt_delete(first_point);\r
+ \r
// ********************\r
// rte or trk trailer\r
// ********************\r
fprintf(gpx_out_file, "\t</rte>\n");\r
else\r
fprintf(gpx_out_file, "\t\t</trkseg>\n\t</trk>\n");\r
+ \r
+ break;\r
\r
case ANNOT_TYPE_OVAL:\r
- case ANNOT_TYPE_TEXT:\r
case ANNOT_TYPE_CIRCLE:\r
+\r
+ if (annot_version==3)\r
+ {\r
+ data_os=ANNOT_RECOS_TEXT;\r
+ // FIXME get this from buf\r
+ c_shape_points=61;\r
+ point_os = ANNOT_RECOS_OVAL_POINTOS;\r
+ }\r
+ else if (annot_version==4)\r
+ {\r
+ data_os=ANNOT_RECOS_TEXT + 4;\r
+ point_os = ANNOT_RECOS_OVAL_POINTOS + 4;\r
+ c_shape_points=33;\r
+ }\r
+ else\r
+ {\r
+ printf("Unexpected annotation version %d\n", annot_version);\r
+ return;\r
+ }\r
+\r
+ //otail = (struct f_annotation_oval_tail *)(rec->buf + data_os);\r
+\r
+ // ************\r
+ // trk header\r
+ // ************\r
+\r
+ fprintf(gpx_out_file, "\t<trk>\n");\r
+\r
+ fprintf(gpx_out_file, "\t\t<name>");\r
+ if (rec->text==NULL)\r
+ fprintf(gpx_out_file, "TK%04d\n", rec->annot_num);\r
+ else\r
+ fprintf(gpx_out_file, rec->text);\r
+ fprintf(gpx_out_file, "</name>\n");\r
+\r
+ fprintf(gpx_out_file, "\t\t<src>Extracted from Annotation %d (%s)</src>\n",\r
+ rec->annot_num, annot_type_name[rec->type]);\r
+ fprintf(gpx_out_file, "\t\t<trkseg>\n");\r
+\r
+ // ************\r
+ // trk points\r
+ // ************\r
+\r
+ for (p=0; p < c_shape_points; p++, pt_num++)\r
+ {\r
+ pt=gpx_get_point(rec->buf + point_os + 12*p);\r
+ // I wanted to keep pt names less that 6 chars, \r
+ // but there can be large polylines e.g with more than 30,000 pts\r
+ if(pt_num>9999999)\r
+ {\r
+ printf("Too many points\n");\r
+ exit(0);\r
+ }\r
+ pt->name=(char*)xmalloc(10);\r
+ if(pt==NULL)\r
+ {\r
+ printf("got null pt #%p in annotation %d, skipping more points in this annotation\n",\r
+ p, rec->annot_num);\r
+ break;\r
+ }\r
+ if(opts.use_gpx_route)\r
+ sprintf(pt->name, "rp%04d", pt_num);\r
+ else\r
+ // we need to include a name for trackpoints\r
+ // for them to be recognised by easygps.\r
+ sprintf(pt->name, "tp%04d", pt_num);\r
+ gpx_write_point(gpx_out_file, pt, pt_type);\r
+ if(p==0)\r
+ first_point = gpxpt_copy(pt);\r
+ gpxpt_delete(pt);\r
+ }\r
+ //close the loop\r
+ gpx_write_point(gpx_out_file, first_point, pt_type);\r
+ gpxpt_delete(first_point);\r
+\r
+ // *************\r
+ // trk trailer\r
+ // *************\r
+\r
+ fprintf(gpx_out_file, "\t\t</trkseg>\n\t</trk>\n");\r
+\r
+ break;\r
+ case ANNOT_TYPE_TEXT:\r
default:\r
break;\r
}\r
void gpx_write_annotations(FILE* gpx_out_file, struct annotations * annots)\r
{\r
int i;\r
+\r
+ if(annots->num_annotations == 0)\r
+ return;\r
+\r
+ if(opts.use_gpx_route)\r
+ printf("writing gpx routes for %d annotations\n", annots->num_annotations);\r
+ else\r
+ printf("writing gpx tracks for %d annotations\n", annots->num_annotations);\r
+\r
if ( (gpx_out_file!=NULL) && (annots!=NULL) )\r
for (i=0; i < annots->num_annotations; i++)\r
{\r
- gpx_write_annot_rec(gpx_out_file, annots->annot_list[i]);\r
+ gpx_write_annot_rec(gpx_out_file, annots->annot_list[i], annots->version);\r
}\r
}\r
\r
if ( (ppplist==NULL) && (jour==NULL) && (annots==NULL) )\r
return;\r
gpx_out_file = gpx_open_write_file_header(gpx_out_file_name);\r
+ pt_num=0;\r
gpx_write_pushpinlist(gpx_out_file, ppplist);\r
gpx_write_journey(gpx_out_file, jour);\r
gpx_write_annotations(gpx_out_file, annots);\r
/*\r
writepcx.c\r
\r
- Extract data from MS Streets & Trips .est and Autoroute .axe files in GPX format.\r
+ Extract data from MS Streets & Trips .est, Autoroute .axe \r
+ and Mapoint .ptm files in GPX format.\r
\r
Copyright (C) 2003 James Sherring, james_sherring@yahoo.com\r
\r
// FIXME this should come from the pushpin icon\r
int symbol=8; // or 18\r
\r
- strpad(timedate, 19);\r
+ // 18 or 19?\r
+ strpad(timedate, 18);\r
\r
// Should I create a meaningful note if there is none?\r
if(ppin->NoteShort)\r
{\r
char timedate[19]="";\r
float alt=0;\r
- char desc[40];\r
+ char desc[41];\r
float proximity=0;\r
\r
int symbol=8; // or 18\r
// {\r
f_wpt_head = (struct f_jour_pt_head *)(jour->buf + (rtept->pthead_os));\r
\r
- strpad(timedate, 19);\r
+ strpad(timedate, 18);\r
\r
memcpy(desc, rtept->text1,39);\r
strpad(desc, 40);\r
fprintf(file, "\n");\r
fprintf(file, GAR_TRK_HEADER);\r
\r
- strpad(timedate, 19);\r
+ // fixme - 18/19\r
+ strpad(timedate, 18);\r
\r
for(p=0; p<pannot->line_points; p++)\r
{\r